Changeset 3343 for libpipi


Ignore:
Timestamp:
Jan 13, 2009, 12:51:36 AM (12 years ago)
Author:
Sam Hocevar
Message:

Got rid of the modular codec stuff. All codecs should work the same way.

Location:
libpipi/trunk
Files:
2 deleted
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/configure.ac

    r3162 r3343  
    178178AM_CONDITIONAL(USE_COCOA, test "${ac_cv_my_have_cocoa}" = "yes")
    179179
    180 
    181 # Use Modular codecs ?
    182 MODULAR_CODEC=""
    183 ac_cv_my_have_modular="no"
    184 
    185 ac_cv_my_have_libjpeg="no"
     180# Use libjpeg?
     181ac_cv_my_have_jpeg="no"
    186182AC_CHECK_HEADERS(jpeglib.h,
    187  [ac_cv_my_have_libjpeg="yes"],
    188  [ac_cv_my_have_libjpeg="no"])
    189 if test "${ac_cv_my_have_libjpeg}" != "no"; then
    190   ac_cv_my_have_modular="yes"
    191   AC_DEFINE(USE_LIBJPEG, 1, Define to 1 to use libjpeg)
    192   AC_DEFINE(USE_MODULAR, 1, Define to 1 to use modular codecs)
    193   MODULAR_CODEC="${MODULAR_CODEC} libjpeg"
    194 fi
    195 AM_CONDITIONAL(USE_LIBJPEG, test "${ac_cv_my_have_libjpeg}" = "yes")
    196 AM_CONDITIONAL(USE_MODULAR, test "${ac_cv_my_have_modular}" = "yes")
    197 
    198 AC_MSG_CHECKING(valid modular codecs)
    199 if test -z "${MODULAR_CODEC}"; then
    200   AC_MSG_RESULT(none)
    201 else
    202   MODULAR_CODEC="${MODULAR_CODEC# *}"
    203   AC_MSG_RESULT([${MODULAR_CODEC}])
    204 fi
    205 
    206 if test "${ac_cv_my_have_sdl}" = "no" -a "${ac_cv_my_have_imlib2}" = "no" -a "${ac_cv_my_have_opencv}" = "no" -a "${ac_cv_my_have_cocoa}" = "no" -a "${ac_cv_my_have_modular}" = "no"; then
     183 [ac_cv_my_have_jpeg="yes"],
     184 [ac_cv_my_have_jpeg="no"])
     185if test "${ac_cv_my_have_jpeg}" != "no"; then
     186  AC_DEFINE(USE_JPEG, 1, Define to 1 to use libjpeg)
     187fi
     188AM_CONDITIONAL(USE_JPEG, test "${ac_cv_my_have_jpeg}" = "yes")
     189
     190if test "${ac_cv_my_have_sdl}" = "no" -a "${ac_cv_my_have_imlib2}" = "no" -a "${ac_cv_my_have_opencv}" = "no" -a "${ac_cv_my_have_cocoa}" = "no" -a "${ac_cv_my_have_jpeg}" = "no"; then
    207191  AC_MSG_ERROR([[cannot find GDI+, SDL_Image, Imlib2, Cocoa or OpenCV, please install one of them]])
    208192fi
  • libpipi/trunk/pipi/Makefile.am

    r3339 r3343  
    125125endif
    126126
    127 # Modular codecs
    128 if USE_MODULAR
    129 codec_sources += codec/modular.c
    130 if USE_LIBJPEG
     127if USE_JPEG
    131128codec_libs += -ljpeg
    132 codec_sources += codec/modular/jpeg.c
     129codec_sources += codec/jpeg.c
    133130endif
    134 endif
     131
  • libpipi/trunk/pipi/codec.c

    r3100 r3343  
    3939        ret = pipi_load_oric(name);
    4040
     41#if USE_JPEG
     42    if(!ret)
     43        ret = pipi_load_jpeg(name);
     44#endif
    4145#if USE_IMLIB2
    4246    if(!ret)
     
    6266    if(!ret)
    6367        ret = pipi_load_coreimage(name);
    64 #endif
    65 #if USE_MODULAR
    66     if(!ret)
    67         ret = pipi_load_modular(name);
    6868#endif
    6969    return ret;
     
    9191        ret = pipi_save_oric(img, name);
    9292
    93 #if USE_MODULAR
     93#if USE_JPEG
    9494    if(ret < 0)
    95         ret = pipi_save_modular(img, name);
     95        ret = pipi_save_jpeg(img, name);
    9696#endif
    9797#if USE_IMLIB2
  • libpipi/trunk/pipi/codec/jpeg.c

    r3342 r3343  
    1818 */
    1919
    20 #include "../modular.h"
     20#include "config.h"
     21
     22#include <stdio.h>
     23#include <stdlib.h>
     24#include <string.h>
     25#include <ctype.h>
    2126#include <setjmp.h>
    2227
     28#include <jpeglib.h>
     29
     30#include "pipi.h"
     31#include "pipi_internals.h"
     32
    2333static int pipi_free_jpeg(pipi_image_t *img);
    24 
    25 
    26 
    2734
    2835struct my_error_mgr {
     
    5663    pipi_image_t *img = NULL;
    5764    unsigned int i, j, k = 0;
    58 
    59     FILE *fp = fopen(name, "rb");
     65    FILE *fp;
     66
     67    fp = fopen(name, "rb");
    6068    if(!fp) goto end;
    6169
     
    143151    unsigned char *data = NULL;
    144152    unsigned char *line = NULL;
     153    size_t len;
     154
     155    len = strlen(name);
     156    if(len < 4 || name[len - 4] != '.'
     157        || toupper(name[len - 3]) != 'J'
     158        || toupper(name[len - 2]) != 'P'
     159        || toupper(name[len - 1]) != 'G')
     160    {
     161        if(len < 5 || name[len - 5] != '.'
     162            || toupper(name[len - 4]) != 'J'
     163            || toupper(name[len - 3]) != 'P'
     164            || toupper(name[len - 2]) != 'E'
     165            || toupper(name[len - 1]) != 'G')
     166            return -1;
     167    }
    145168
    146169    pipi_pixels_t *pixels = pipi_get_pixels(img, PIPI_PIXELS_RGBA_U8);
  • libpipi/trunk/pipi/pipi_internals.h

    r3339 r3343  
    119119#endif
    120120
    121 /* Modular codecs */
    122 #ifdef USE_MODULAR
    123 pipi_image_t *pipi_load_modular(const char *name);
    124 int pipi_save_modular(pipi_image_t *img, const char *name);
     121#ifdef USE_JPEG
     122pipi_image_t *pipi_load_jpeg(const char *name);
     123int pipi_save_jpeg(pipi_image_t *img, const char *name);
    125124#endif
    126 
    127 
    128125
    129126pipi_image_t *pipi_load_oric(const char *name);
Note: See TracChangeset for help on using the changeset viewer.