mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 14:34:33 +02:00
move src/extras to the top-level
reserve src/ for the code of the main libraries: libwebp, libwebpdemux and libwebpmux + demote this library to internal only; i.e., don't install the header + lib with make install Change-Id: I8c9844db8f494be0fa0a2549a5b75b5cebcf666d
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
# The mux, demux and extras libraries depend on libwebp, thus the '.' to force
|
||||
# The mux and demux libraries depend on libwebp, thus the '.' to force
|
||||
# the build order so it's available to them.
|
||||
SUBDIRS = dec enc dsp utils .
|
||||
if WANT_MUX
|
||||
@ -7,9 +7,6 @@ endif
|
||||
if WANT_DEMUX
|
||||
SUBDIRS += demux
|
||||
endif
|
||||
if WANT_EXTRAS
|
||||
SUBDIRS += extras
|
||||
endif
|
||||
|
||||
lib_LTLIBRARIES = libwebp.la
|
||||
|
||||
|
@ -1,13 +0,0 @@
|
||||
lib_LTLIBRARIES = libwebpextras.la
|
||||
|
||||
libwebpextras_la_SOURCES =
|
||||
libwebpextras_la_SOURCES += extras.c
|
||||
|
||||
libwebpextrasinclude_HEADERS =
|
||||
libwebpextrasinclude_HEADERS += ../webp/extras.h
|
||||
libwebpextrasinclude_HEADERS += ../webp/types.h
|
||||
|
||||
libwebpextras_la_LIBADD = ../libwebp.la
|
||||
libwebpextras_la_LDFLAGS = -no-undefined -version-info 0:0:0
|
||||
libwebpextrasincludedir = $(includedir)/webp
|
||||
pkgconfig_DATA = libwebpextras.pc
|
@ -1,111 +0,0 @@
|
||||
// Copyright 2015 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// Additional WebP utilities.
|
||||
//
|
||||
|
||||
#include "../webp/extras.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define XTRA_MAJ_VERSION 0
|
||||
#define XTRA_MIN_VERSION 0
|
||||
#define XTRA_REV_VERSION 0
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
int WebPGetExtrasVersion(void) {
|
||||
return (XTRA_MAJ_VERSION << 16) | (XTRA_MIN_VERSION << 8) | XTRA_REV_VERSION;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
int WebPImportGray(const uint8_t* gray_data, WebPPicture* pic) {
|
||||
int y, width, uv_width;
|
||||
if (pic == NULL || gray_data == NULL) return 0;
|
||||
pic->colorspace = WEBP_YUV420;
|
||||
if (!WebPPictureAlloc(pic)) return 0;
|
||||
width = pic->width;
|
||||
uv_width = (width + 1) >> 1;
|
||||
for (y = 0; y < pic->height; ++y) {
|
||||
memcpy(pic->y + y * pic->y_stride, gray_data, width);
|
||||
gray_data += width; // <- we could use some 'data_stride' here if needed
|
||||
if ((y & 1) == 0) {
|
||||
memset(pic->u + (y >> 1) * pic->uv_stride, 128, uv_width);
|
||||
memset(pic->v + (y >> 1) * pic->uv_stride, 128, uv_width);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int WebPImportRGB565(const uint8_t* rgb565, WebPPicture* pic) {
|
||||
int x, y;
|
||||
if (pic == NULL || rgb565 == NULL) return 0;
|
||||
pic->colorspace = WEBP_YUV420;
|
||||
pic->use_argb = 1;
|
||||
if (!WebPPictureAlloc(pic)) return 0;
|
||||
for (y = 0; y < pic->height; ++y) {
|
||||
const int width = pic->width;
|
||||
uint32_t* dst = pic->argb + y * pic->argb_stride;
|
||||
for (x = 0; x < width; ++x) {
|
||||
#ifdef WEBP_SWAP_16BIT_CSP
|
||||
const uint32_t rg = rgb565[2 * x + 1];
|
||||
const uint32_t gb = rgb565[2 * x + 0];
|
||||
#else
|
||||
const uint32_t rg = rgb565[2 * x + 0];
|
||||
const uint32_t gb = rgb565[2 * x + 1];
|
||||
#endif
|
||||
uint32_t r = rg & 0xf8;
|
||||
uint32_t g = ((rg << 5) | (gb >> 3)) & 0xfc;
|
||||
uint32_t b = (gb << 5);
|
||||
// dithering
|
||||
r = r | (r >> 5);
|
||||
g = g | (g >> 6);
|
||||
b = b | (b >> 5);
|
||||
dst[x] = (r << 16) | (g << 8) | b;
|
||||
}
|
||||
rgb565 += 2 * width;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int WebPImportRGB4444(const uint8_t* rgb4444, WebPPicture* pic) {
|
||||
int x, y;
|
||||
if (pic == NULL || rgb4444 == NULL) return 0;
|
||||
pic->colorspace = WEBP_YUV420;
|
||||
pic->use_argb = 1;
|
||||
if (!WebPPictureAlloc(pic)) return 0;
|
||||
for (y = 0; y < pic->height; ++y) {
|
||||
const int width = pic->width;
|
||||
uint32_t* dst = pic->argb + y * pic->argb_stride;
|
||||
for (x = 0; x < width; ++x) {
|
||||
#ifdef WEBP_SWAP_16BIT_CSP
|
||||
const uint32_t rg = rgb4444[2 * x + 1];
|
||||
const uint32_t ba = rgb4444[2 * x + 0];
|
||||
#else
|
||||
const uint32_t rg = rgb4444[2 * x + 0];
|
||||
const uint32_t ba = rgb4444[2 * x + 1];
|
||||
#endif
|
||||
uint32_t r = rg & 0xf0;
|
||||
uint32_t g = (rg << 4);
|
||||
uint32_t b = (ba & 0xf0);
|
||||
uint32_t a = (ba << 4);
|
||||
// dithering
|
||||
r = r | (r >> 4);
|
||||
g = g | (g >> 4);
|
||||
b = b | (b >> 4);
|
||||
a = a | (a >> 4);
|
||||
dst[x] = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
rgb4444 += 2 * width;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
@ -1,11 +0,0 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: libwebpextras
|
||||
Description: Additional utility functions useful in processing WebP files
|
||||
Version: @PACKAGE_VERSION@
|
||||
Requires: libwebp >= 0.5.0
|
||||
Cflags: -I${includedir}
|
||||
Libs: -L${libdir} -lwebpextras
|
@ -1,51 +0,0 @@
|
||||
// Copyright 2015 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
#ifndef WEBP_WEBP_EXTRAS_H_
|
||||
#define WEBP_WEBP_EXTRAS_H_
|
||||
|
||||
#include "./types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./encode.h"
|
||||
|
||||
#define WEBP_EXTRAS_ABI_VERSION 0x0000 // MAJOR(8b) + MINOR(8b)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Returns the version number of the extras library, packed in hexadecimal using
|
||||
// 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507.
|
||||
WEBP_EXTERN(int) WebPGetExtrasVersion(void);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Ad-hoc colorspace importers.
|
||||
|
||||
// Import luma sample (gray scale image) into 'picture'. The 'picture'
|
||||
// width and height must be set prior to calling this function.
|
||||
WEBP_EXTERN(int) WebPImportGray(const uint8_t* gray, WebPPicture* picture);
|
||||
|
||||
// Import rgb sample in RGB565 packed format into 'picture'. The 'picture'
|
||||
// width and height must be set prior to calling this function.
|
||||
WEBP_EXTERN(int) WebPImportRGB565(const uint8_t* rgb565, WebPPicture* pic);
|
||||
|
||||
// Import rgb sample in RGB4444 packed format into 'picture'. The 'picture'
|
||||
// width and height must be set prior to calling this function.
|
||||
WEBP_EXTERN(int) WebPImportRGB4444(const uint8_t* rgb4444, WebPPicture* pic);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif /* WEBP_WEBP_EXTRAS_H_ */
|
Reference in New Issue
Block a user