mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 06:24:27 +02:00
Refactor CopyPlane() and CopyPixels() methods: put them in utils.
Change-Id: I0e1533df557a0fa42c670e3b826fc0675c36e0a5
This commit is contained in:
@ -12,7 +12,9 @@
|
||||
// Author: Skal (pascal.massimino@gmail.com)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h> // for memcpy()
|
||||
#include "../webp/decode.h"
|
||||
#include "../webp/encode.h"
|
||||
#include "./utils.h"
|
||||
|
||||
// If PRINT_MEM_INFO is defined, extra info (like total memory used, number of
|
||||
@ -214,3 +216,24 @@ void WebPFree(void* ptr) {
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void WebPCopyPlane(const uint8_t* src, int src_stride,
|
||||
uint8_t* dst, int dst_stride, int width, int height) {
|
||||
assert(src != NULL && dst != NULL);
|
||||
assert(src_stride >= width && dst_stride >= width);
|
||||
while (height-- > 0) {
|
||||
memcpy(dst, src, width);
|
||||
src += src_stride;
|
||||
dst += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
void WebPCopyPixels(const WebPPicture* const src, WebPPicture* const dst) {
|
||||
assert(src != NULL && dst != NULL);
|
||||
assert(src->width == dst->width && src->height == dst->height);
|
||||
assert(src->use_argb && dst->use_argb);
|
||||
WebPCopyPlane((uint8_t*)src->argb, 4 * src->argb_stride, (uint8_t*)dst->argb,
|
||||
4 * dst->argb_stride, 4 * src->width, src->height);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -118,6 +118,21 @@ static WEBP_INLINE int BitsLog2Floor(uint32_t n) {
|
||||
}
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Pixel copying.
|
||||
|
||||
struct WebPPicture;
|
||||
|
||||
// Copy width x height pixels from 'src' to 'dst' honoring the strides.
|
||||
WEBP_EXTERN(void) WebPCopyPlane(const uint8_t* src, int src_stride,
|
||||
uint8_t* dst, int dst_stride,
|
||||
int width, int height);
|
||||
|
||||
// Copy ARGB pixels from 'src' to 'dst' honoring strides. 'src' and 'dst' are
|
||||
// assumed to be already allocated and using ARGB data.
|
||||
WEBP_EXTERN(void) WebPCopyPixels(const struct WebPPicture* const src,
|
||||
struct WebPPicture* const dst);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Reference in New Issue
Block a user