Leptonica 1.68
C Image Processing Library

webpio.c File Reference

Read/write webp format from/to file. More...

#include <math.h>
#include "allheaders.h"
#include "webp/decode.h"
#include "webp/encode.h"

Go to the source code of this file.

Functions

PIXpixReadStreamWebP (FILE *fp)
l_int32 readHeaderWebP (const char *filename, l_int32 *pwidth, l_int32 *pheight)
l_int32 pixWriteWebP (const char *filename, PIX *pixs, l_int32 quality)
l_int32 pixWriteStreamWebP (FILE *fp, PIX *pixs, l_int32 quality)
l_int32 pixWriteWebPwithTargetPSNR (const char *filename, PIX *pixs, l_float64 target_psnr, l_int32 *pquality)

Detailed Description

Read/write webp format from/to file.

  Read WebP from file
        PIX             *pixReadStreamWebP()
        l_int32          readHeaderWebP()

  Write WebP to file
        l_int32          pixWriteWebP()  [ special top level ]
        l_int32          pixWriteStreamWebP()

  Write WebP to file with target psnr
        l_int32          pixWriteWebPwithTargetPSNR

Definition in file webpio.c.


Function Documentation

PIX* pixReadStreamWebP ( FILE *  fp)

pixReadStreamWebP()

Input: stream corresponding to WebP image Return: pix (32 bpp), or null on error

Notes: (1) Use 'free', and not leptonica's 'FREE', for all heap data that is returned from the WebP library.

Definition at line 61 of file webpio.c.

References ERROR_PTR, FREE, l_binaryReadStream(), NULL, pixCreate(), pixDestroy(), pixEndianByteSwap(), pixGetData(), pixGetWpl(), and PROCNAME.

Referenced by pixReadStream().

l_int32 readHeaderWebP ( const char *  filename,
l_int32 pwidth,
l_int32 pheight 
)

readHeaderWebP()

Input: filename &width (<return>) &height (<return>) Return: 0 if OK, 1 on error

Definition at line 114 of file webpio.c.

References ERROR_INT, fopenReadStream(), NULL, and PROCNAME.

Referenced by pixReadHeader().

l_int32 pixWriteWebP ( const char *  filename,
PIX pixs,
l_int32  quality 
)

pixWriteWebP()

Input: filename pixs quality (1 - 100; 75 is default) Return: 0 if OK, 1 on error

Definition at line 154 of file webpio.c.

References ERROR_INT, fopenWriteStream(), NULL, pixWriteStreamWebP(), and PROCNAME.

l_int32 pixWriteStreamWebP ( FILE *  fp,
PIX pixs,
l_int32  quality 
)

pixWriteStreampWebP()

Input: stream pix (all depths) quality (1 - 100; 75 is default) Return: 0 if OK, 1 on error

Notes: (1) webp only encodes rgb images, so the input image is converted to rgb if necessary.

Definition at line 193 of file webpio.c.

References ERROR_INT, NULL, pixConvertTo32(), pixDestroy(), pixEndianByteSwapNew(), pixGetData(), pixGetDepth(), pixGetDimensions(), pixGetWpl(), pixRemoveColormap(), L_WShed::pixt, PROCNAME, and REMOVE_CMAP_TO_FULL_COLOR.

Referenced by pixWriteStream(), and pixWriteWebP().

l_int32 pixWriteWebPwithTargetPSNR ( const char *  filename,
PIX pixs,
l_float64  target_psnr,
l_int32 pquality 
)

pixWriteWebPwithTargetPSNR()

Input: filename pix (all depths) target_psnr (target psnr to control the quality [1 ... 100]) pquality (<optional return>=""> final quality value used to obtain the target_psnr; can be null) Return: 0 if OK, 1 on error

Notes: (1) The parameter to control quality while encoding WebP is quality. This function does a line search over the quality values between MIN_QUALITY and MAX_QUALITY to achieve the target PSNR as close as possible.

Definition at line 275 of file webpio.c.

References ERROR_INT, fopenWriteStream(), L_MAX, L_MIN, NULL, pixConvertTo32(), pixDestroy(), pixGetData(), pixGetDepth(), pixGetDimensions(), pixGetWpl(), pixRemoveColormap(), PROCNAME, and REMOVE_CMAP_TO_FULL_COLOR.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines