PNG  IHDR  8] PLTE S =tRNS   PNG  IHDR  8] PLTE S =tRNS   REDROOM
PHP 7.4.33
Preview: webpimg.h Size: 7.04 KB
//opt/cloudlinux/alt-php55/root/usr/include/php/ext/gd/libgd/webpimg.h

/*===========================================================================*
 - Copyright 2010 Google Inc.
 -
 - This code is licensed under the same terms as WebM:
 - Software License Agreement:  http://www.webmproject.org/license/software/
 - Additional IP Rights Grant:  http://www.webmproject.org/license/additional/
 *===========================================================================*/

/*
 * Encoding/Decoding of WebP still image compression format.
 *
 * 1. WebPDecode: Takes an array of bytes (string) corresponding to the WebP
 *                encoded image and generates output in the YUV format with
 *                the color components U, V subsampled to 1/2 resolution along
 *                each dimension.
 *
 * 2. YUV420toRGBA: Converts from YUV (with color subsampling) such as produced
 *                  by the WebPDecode routine into 32 bits per pixel RGBA data
 *                  array. This data array can be directly used by the Leptonica
 *                  Pix in-memory image format.
 *
 * 3. WebPEncode: Takes a Y, U, V data buffers (with color components U and V
 *                subsampled to 1/2 resolution) and generates the WebP string
 *
 * 4. RGBAToYUV420: Generates Y, U, V data (with color subsampling) from 32 bits
 *                  per pixel RGBA data buffer. The resulting YUV data can be
 *                  directly fed into the WebPEncode routine.
 *
 * 5. AdjustColorspace:
 *
 * 6. AdjustColorspaceBack:
 */

#ifndef THIRD_PARTY_VP8_VP8IMG_H_
#define THIRD_PARTY_VP8_VP8IMG_H_

#ifdef __cplusplus
extern "C" {
#endif  /* __cplusplus */

typedef unsigned char uint8;
typedef unsigned int uint32;
typedef enum WebPResultType {
  webp_success = 0,
  webp_failure = -1
} WebPResult;

/* Takes an array of bytes (string) corresponding to the WebP
 * encoded image and generates output in the YUV format with
 * the color components U, V subsampled to 1/2 resolution along
 * each dimension.
 * Input:
 *      1. data: the WebP data stream (array of bytes)
 *      2. data_size: count of bytes in the WebP data stream
 *
 * Output:
 *      3. p_Y/p_U/p_V : pointer to the Y/U/V data buffer (this routine will
 *                       allocate memory for the buffer, fill the buffer with
 *                       appropriate data and transfer owner ship of the buffer
 *                       to caller. Caller is reponsible for freeing the memory).
 *                       Note that the memory for Y, U, V buffers is alloacted
 *                       in one chunk, hence one should call free(*p_Y) only.
 *                       Do not try to free the U and V buffers.
 *
 *      6. p_width: this routine returns the width of the decoded image here
 *      7. p_height: this routine returns the width of the decoded image here
 * Return: success/failure
 */
WebPResult WebPDecode(const uint8* data,
                      int data_size,
                      uint8** p_Y,
                      uint8** p_U,
                      uint8** p_V,
                      int* p_width,
                      int* p_height);

/* WebPEncode: Takes a Y, U, V data buffers (with color components U and V
 *             subsampled to 1/2 resolution) and generates the WebP string.
 * Input:
 *      1, 2, 3. Y, U, V: The input YUV data buffers
 *      4, 5. y_width, y_height: The width and height of the image whose data
 *                               is in Y, U, V. This matches the Y plane. The U
 *                               and V planes typically have 1/2 width and
 *                               height.
 *      6. y_stride: The width (in bytes) of one row of Y data. This may not
 *                   match width if there is end of row padding (e.g., for 32
 *                   bit row alignment).
 *      7. QP: the quantization parameter. This parameter controls the
 *             compression vs quality tradeoff. Use smaller numbers for better
 *             quality (compression will be lesser) and vice versa. 20 is a
 *             good optimal value.
 * Output:
 *      8. p_out: the output array of bytes corresponding to the encoded WebP
 *                image. This routine allocates memory for the buffer, fills it
 *                with appropriate values and transfers ownership to caller.
 *                Caller responsible for freeing of memory.
 * Return: success/failure
 */
WebPResult WebPEncode(const uint8* Y,
                      const uint8* U,
                      const uint8* V,
                      int y_width,
                      int y_height,
                      int y_stride,
                      int uv_width,
                      int uv_height,
                      int uv_stride,
                      int QP,
                      unsigned char** p_out,
                      int* p_out_size_bytes,
                      double* psnr);

/* Converts from YUV (with color subsampling) such as produced by the WebPDecode
 * routine into 32 bits per pixel RGBA data array. This data array can be
 * directly used by the Leptonica Pix in-memory image format.
 * Input:
 *      1, 2, 3. Y, U, V: the input data buffers
 *      4. pixwpl: the desired words per line corresponding to the supplied
 *                 output pixdata.
 *      5. width, height: the dimensions of the image whose data resides in Y,
 *                        U, V.
 * Output:
 *     6. pixdata: the output data buffer. Caller should allocate
 *                 height * pixwpl bytes of memory before calling this routine.
 */
void YUV420toRGBA(uint8* Y,
                  uint8* U,
                  uint8* V,
                  int words_per_line,
                  int width,
                  int height,
                  uint32* pixdata);

/* Generates Y, U, V data (with color subsampling) from 32 bits
 * per pixel RGBA data buffer. The resulting YUV data can be directly fed into
 * the WebPEncode routine.
 * Input:
 *    1. pix data input rgba data buffer
 *    2. words per line corresponding to pixdata
 *    3, 4. image width and height respectively
 * Output:
 *    5, 6, 7. Output YUV data buffers
 */
void RGBAToYUV420(uint32* pixdata,
                  int words_per_line,
                  int width,
                  int height,
                  uint8* Y,
                  uint8* U,
                  uint8* V);

/* This function adjust from YUV420J (jpeg decoding) to YUV420 (webp input)
 * Hints: http://en.wikipedia.org/wiki/YCbCr
 */
void AdjustColorspace(uint8* Y, uint8* U, uint8* V, int width, int height);

/* Inverse function: convert from YUV420 to YUV420J */
void AdjustColorspaceBack(uint8* Y, uint8* U, uint8* V, int width, int height);

/* Checks WebP image header and outputs height and width information of
 * the image
 *
 * Input:
 *      1. data: the WebP data stream (array of bytes)
 *      2. data_size: count of bytes in the WebP data stream
 *
 * Outut:
 *      width/height: width and height of the image
 *
 * Return: success/failure
 */
WebPResult WebPGetInfo(const uint8* data,
                       int data_size,
                       int *width,
                       int *height);

#ifdef __cplusplus
}
#endif  /* __cplusplus */

#endif  /* THIRD_PARTY_VP8_VP8IMG_H_ */

Directory Contents

Dirs: 0 × Files: 13

Name Size Perms Modified Actions
32.07 KB lrw-r--r-- 2026-04-20 14:04:19
Edit Download
2.65 KB lrw-r--r-- 2026-04-20 14:04:19
Edit Download
529 B lrw-r--r-- 2026-04-20 14:04:19
Edit Download
527 B lrw-r--r-- 2026-04-20 14:04:19
Edit Download
495 B lrw-r--r-- 2026-04-20 14:04:19
Edit Download
491 B lrw-r--r-- 2026-04-20 14:04:19
Edit Download
522 B lrw-r--r-- 2026-04-20 14:04:19
Edit Download
1.32 KB lrw-r--r-- 2026-04-20 14:04:19
Edit Download
261 B lrw-r--r-- 2026-04-20 14:04:19
Edit Download
963 B lrw-r--r-- 2026-04-20 14:04:19
Edit Download
69.68 KB lrw-r--r-- 2026-04-20 14:04:19
Edit Download
1.25 KB lrw-r--r-- 2026-04-20 14:04:19
Edit Download
7.04 KB lrw-r--r-- 2026-04-20 14:04:19
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).
 !"#$%&'(()*+,-./00123456789 t\ wIDATx ]ys  47Y ƒ -  "  Rv  < f{Ɛ $k l L > L  ~h^ 1  [  r G t& h  l F z3O Y ! p A(_g̷ E8 )S 8 c  Kb"z ~ 5 J xAL WU <  *  5 m;W a pB h ~P J 2 3 6 ҙ .Ƹ P i  4g F R L P ΪK/D  M v (a3 k J Œ4N5* SH ` SdJ z  O J Xՠ V>u ߱ BE&L b2 ?2` tX+  c CB A$ i b C ĀMB E : /  # Dx &l =q Ty  0 \p I ( L Ǎ { e 4k ;`u^ヲ eP!( d {  )T A 8 O;Ě n >;s6 !  :Nx `[S D HU ~ q›J F} a g*D 49 / pn k h (t 8NxƐF _!r չ7 ZR R׷ q/5") Ӎ NY 0 x sZ!   o  fu  ,  K"$ ? pg  㕣=  1» {h " fh7    y  } € +7  $ y " X —ą - G P u 4 m >J 5 L =V ' ^@I p ?MS xЌ XV P ! h "C NS9B8̢ ]!K  e   zA , ӏkbY  !< XQ ٿyS| *" f { w  4@[S <  # 0 ! js [m  =,~ o "ݎ DHf Wo $ g ! Vԅ t mB /y Wf V4񺍸 c+@x?  B ~u " xUN e 0 BĂ) ~J pz! 7y6]l Ԥ@ P a< O /DHC `≻  N m"$  0ObB }{ x AO FCG D R ^ "B  { WDH  UR l@ T #  +"d T ; 0 i  D}. 7 ` ' ] w rE &S i ƕiTD EL P _ u h $ Ա FG wVD G L R Zf ' .!] J /ZR oGЍs Mr Ĥ ʬ 3 Q [3 cL ` ^ p + ( F;# B 5 '  2Y f [  ϶R0e }  E 7 6M aۮ H <& n % L] E}Up x紉, Uw' Q  Ǯշo k ވۙ 0N94 VX5 xEDE l D #֤ } C o )W :  ^ s 9  bRf iX5u ཱི 4 :[  T 1. | [E 2ؽ Iy\ : o x K G 5 ylP ' uK E ftb/i[3 .g _  [3M n G, #NwQ5~  ؚ) | n =Ц"x qg gB ` 듘 ~ x w ? ? R~  _ u. &VQ K˻   H C ( TN˄+ `C dA nB׭ D 3"Z G ê ^k H_ /- ~ " R_  .8 Z_ 6@ o  xg  uP ? 3լ @7AM!  E7^ - =V L  x  g-D0  CtmW 7  O  G _ WD0 g C  w1 r d w : a | \  *" f nֳ ^ H# f L ` Z ۽hV  }S F r0Ù Bć5r] @! NL iQ]{s^=4 d  WD  "  "   M; t" 8 5 e dL| "-*st" ) SWD ?R[S e ooF  20.D ? bo =) A i o d ģ ZҰaO @E =) i D a &ܟa CϞ y6 ,<%{^x%{f8? `iw^ ?/ M * IEND B`