mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 13:48:21 +01:00
Merge changes I2877e7bb,I777cad70,I15af7d1a,I686e6740,If10538a9, ... into main
* changes: picture_csp_enc.c: remove SafeInitSharpYuv sharpyuv: prefer webp/types.h sharpyuv,SharpYuvInit: add mutex protection when available sharyuv_{neon,sse2}.c: merge WEBP_USE_* sections add a few missing <stddef.h> includes for NULL sharpyuv.h: remove <inttypes.h>
This commit is contained in:
commit
62b1bfe8bd
@ -12,6 +12,7 @@ libsharpyuvinclude_HEADERS += sharpyuv.h
|
|||||||
libsharpyuvinclude_HEADERS += sharpyuv_csp.h
|
libsharpyuvinclude_HEADERS += sharpyuv_csp.h
|
||||||
noinst_HEADERS =
|
noinst_HEADERS =
|
||||||
noinst_HEADERS += ../src/dsp/cpu.h
|
noinst_HEADERS += ../src/dsp/cpu.h
|
||||||
|
noinst_HEADERS += ../src/webp/types.h
|
||||||
|
|
||||||
libsharpyuv_sse2_la_SOURCES =
|
libsharpyuv_sse2_la_SOURCES =
|
||||||
libsharpyuv_sse2_la_SOURCES += sharpyuv_sse2.c
|
libsharpyuv_sse2_la_SOURCES += sharpyuv_sse2.c
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -414,6 +414,22 @@ static int DoSharpArgbToYuv(const uint8_t* r_ptr, const uint8_t* g_ptr,
|
|||||||
}
|
}
|
||||||
#undef SAFE_ALLOC
|
#undef SAFE_ALLOC
|
||||||
|
|
||||||
|
#if defined(WEBP_USE_THREAD) && !defined(_WIN32)
|
||||||
|
#include <pthread.h> // NOLINT
|
||||||
|
|
||||||
|
#define LOCK_ACCESS \
|
||||||
|
static pthread_mutex_t sharpyuv_lock = PTHREAD_MUTEX_INITIALIZER; \
|
||||||
|
if (pthread_mutex_lock(&sharpyuv_lock)) return
|
||||||
|
#define UNLOCK_ACCESS_AND_RETURN \
|
||||||
|
do { \
|
||||||
|
(void)pthread_mutex_unlock(&sharpyuv_lock); \
|
||||||
|
return; \
|
||||||
|
} while (0)
|
||||||
|
#else // !(defined(WEBP_USE_THREAD) && !defined(_WIN32))
|
||||||
|
#define LOCK_ACCESS do {} while (0)
|
||||||
|
#define UNLOCK_ACCESS_AND_RETURN return
|
||||||
|
#endif // defined(WEBP_USE_THREAD) && !defined(_WIN32)
|
||||||
|
|
||||||
// Hidden exported init function.
|
// Hidden exported init function.
|
||||||
// By default SharpYuvConvert calls it with NULL. If needed, users can declare
|
// By default SharpYuvConvert calls it with NULL. If needed, users can declare
|
||||||
// it as extern and call it with a VP8CPUInfo function.
|
// it as extern and call it with a VP8CPUInfo function.
|
||||||
@ -421,10 +437,12 @@ SHARPYUV_EXTERN void SharpYuvInit(VP8CPUInfo cpu_info_func);
|
|||||||
void SharpYuvInit(VP8CPUInfo cpu_info_func) {
|
void SharpYuvInit(VP8CPUInfo cpu_info_func) {
|
||||||
static volatile VP8CPUInfo sharpyuv_last_cpuinfo_used =
|
static volatile VP8CPUInfo sharpyuv_last_cpuinfo_used =
|
||||||
(VP8CPUInfo)&sharpyuv_last_cpuinfo_used;
|
(VP8CPUInfo)&sharpyuv_last_cpuinfo_used;
|
||||||
|
LOCK_ACCESS;
|
||||||
|
{
|
||||||
const int initialized =
|
const int initialized =
|
||||||
(sharpyuv_last_cpuinfo_used != (VP8CPUInfo)&sharpyuv_last_cpuinfo_used);
|
(sharpyuv_last_cpuinfo_used != (VP8CPUInfo)&sharpyuv_last_cpuinfo_used);
|
||||||
if (cpu_info_func == NULL && initialized) return;
|
if (cpu_info_func == NULL && initialized) UNLOCK_ACCESS_AND_RETURN;
|
||||||
if (sharpyuv_last_cpuinfo_used == cpu_info_func) return;
|
if (sharpyuv_last_cpuinfo_used == cpu_info_func) UNLOCK_ACCESS_AND_RETURN;
|
||||||
|
|
||||||
SharpYuvInitDsp(cpu_info_func);
|
SharpYuvInitDsp(cpu_info_func);
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
@ -432,6 +450,8 @@ void SharpYuvInit(VP8CPUInfo cpu_info_func) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sharpyuv_last_cpuinfo_used = cpu_info_func;
|
sharpyuv_last_cpuinfo_used = cpu_info_func;
|
||||||
|
}
|
||||||
|
UNLOCK_ACCESS_AND_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SharpYuvConvert(const void* r_ptr, const void* g_ptr,
|
int SharpYuvConvert(const void* r_ptr, const void* g_ptr,
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
#ifndef WEBP_SHARPYUV_SHARPYUV_H_
|
#ifndef WEBP_SHARPYUV_SHARPYUV_H_
|
||||||
#define WEBP_SHARPYUV_SHARPYUV_H_
|
#define WEBP_SHARPYUV_SHARPYUV_H_
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
static int ToFixed16(float f) { return (int)floor(f * (1 << 16) + 0.5f); }
|
static int ToFixed16(float f) { return (int)floor(f * (1 << 16) + 0.5f); }
|
||||||
|
|
||||||
|
@ -12,9 +12,8 @@
|
|||||||
#ifndef WEBP_SHARPYUV_SHARPYUV_DSP_H_
|
#ifndef WEBP_SHARPYUV_SHARPYUV_DSP_H_
|
||||||
#define WEBP_SHARPYUV_SHARPYUV_DSP_H_
|
#define WEBP_SHARPYUV_SHARPYUV_DSP_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "src/dsp/cpu.h"
|
#include "src/dsp/cpu.h"
|
||||||
|
#include "src/webp/types.h"
|
||||||
|
|
||||||
extern uint64_t (*SharpYuvUpdateY)(const uint16_t* src, const uint16_t* ref,
|
extern uint64_t (*SharpYuvUpdateY)(const uint16_t* src, const uint16_t* ref,
|
||||||
uint16_t* dst, int len, int bit_depth);
|
uint16_t* dst, int len, int bit_depth);
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "src/webp/types.h"
|
#include "src/webp/types.h"
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#ifndef WEBP_SHARPYUV_SHARPYUV_GAMMA_H_
|
#ifndef WEBP_SHARPYUV_SHARPYUV_GAMMA_H_
|
||||||
#define WEBP_SHARPYUV_SHARPYUV_GAMMA_H_
|
#define WEBP_SHARPYUV_SHARPYUV_GAMMA_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include "src/webp/types.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -17,11 +17,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <arm_neon.h>
|
#include <arm_neon.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
extern void InitSharpYuvNEON(void);
|
|
||||||
|
|
||||||
#if defined(WEBP_USE_NEON)
|
|
||||||
|
|
||||||
static uint16_t clip_NEON(int v, int max) {
|
static uint16_t clip_NEON(int v, int max) {
|
||||||
return (v < 0) ? 0 : (v > max) ? max : (uint16_t)v;
|
return (v < 0) ? 0 : (v > max) ? max : (uint16_t)v;
|
||||||
@ -169,6 +164,8 @@ static void SharpYuvFilterRow_NEON(const int16_t* A, const int16_t* B, int len,
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
extern void InitSharpYuvNEON(void);
|
||||||
|
|
||||||
WEBP_TSAN_IGNORE_FUNCTION void InitSharpYuvNEON(void) {
|
WEBP_TSAN_IGNORE_FUNCTION void InitSharpYuvNEON(void) {
|
||||||
SharpYuvUpdateY = SharpYuvUpdateY_NEON;
|
SharpYuvUpdateY = SharpYuvUpdateY_NEON;
|
||||||
SharpYuvUpdateRGB = SharpYuvUpdateRGB_NEON;
|
SharpYuvUpdateRGB = SharpYuvUpdateRGB_NEON;
|
||||||
@ -177,6 +174,8 @@ WEBP_TSAN_IGNORE_FUNCTION void InitSharpYuvNEON(void) {
|
|||||||
|
|
||||||
#else // !WEBP_USE_NEON
|
#else // !WEBP_USE_NEON
|
||||||
|
|
||||||
|
extern void InitSharpYuvNEON(void);
|
||||||
|
|
||||||
void InitSharpYuvNEON(void) {}
|
void InitSharpYuvNEON(void) {}
|
||||||
|
|
||||||
#endif // WEBP_USE_NEON
|
#endif // WEBP_USE_NEON
|
||||||
|
@ -16,11 +16,6 @@
|
|||||||
#if defined(WEBP_USE_SSE2)
|
#if defined(WEBP_USE_SSE2)
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <emmintrin.h>
|
#include <emmintrin.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
extern void InitSharpYuvSSE2(void);
|
|
||||||
|
|
||||||
#if defined(WEBP_USE_SSE2)
|
|
||||||
|
|
||||||
static uint16_t clip_SSE2(int v, int max) {
|
static uint16_t clip_SSE2(int v, int max) {
|
||||||
return (v < 0) ? 0 : (v > max) ? max : (uint16_t)v;
|
return (v < 0) ? 0 : (v > max) ? max : (uint16_t)v;
|
||||||
@ -199,6 +194,8 @@ WEBP_TSAN_IGNORE_FUNCTION void InitSharpYuvSSE2(void) {
|
|||||||
}
|
}
|
||||||
#else // !WEBP_USE_SSE2
|
#else // !WEBP_USE_SSE2
|
||||||
|
|
||||||
|
extern void InitSharpYuvSSE2(void);
|
||||||
|
|
||||||
void InitSharpYuvSSE2(void) {}
|
void InitSharpYuvSSE2(void) {}
|
||||||
|
|
||||||
#endif // WEBP_USE_SSE2
|
#endif // WEBP_USE_SSE2
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#ifndef WEBP_DSP_CPU_H_
|
#ifndef WEBP_DSP_CPU_H_
|
||||||
#define WEBP_DSP_CPU_H_
|
#define WEBP_DSP_CPU_H_
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "src/webp/config.h"
|
#include "src/webp/config.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -172,21 +172,6 @@ static const int kMinDimensionIterativeConversion = 4;
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Main function
|
// Main function
|
||||||
|
|
||||||
extern void SharpYuvInit(VP8CPUInfo cpu_info_func);
|
|
||||||
|
|
||||||
static void SafeInitSharpYuv(void) {
|
|
||||||
#if defined(WEBP_USE_THREAD) && !defined(_WIN32)
|
|
||||||
static pthread_mutex_t initsharpyuv_lock = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
if (pthread_mutex_lock(&initsharpyuv_lock)) return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SharpYuvInit(VP8GetCPUInfo);
|
|
||||||
|
|
||||||
#if defined(WEBP_USE_THREAD) && !defined(_WIN32)
|
|
||||||
(void)pthread_mutex_unlock(&initsharpyuv_lock);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static int PreprocessARGB(const uint8_t* r_ptr,
|
static int PreprocessARGB(const uint8_t* r_ptr,
|
||||||
const uint8_t* g_ptr,
|
const uint8_t* g_ptr,
|
||||||
const uint8_t* b_ptr,
|
const uint8_t* b_ptr,
|
||||||
@ -483,6 +468,8 @@ static WEBP_INLINE void ConvertRowsToUV(const uint16_t* rgb,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern void SharpYuvInit(VP8CPUInfo cpu_info_func);
|
||||||
|
|
||||||
static int ImportYUVAFromRGBA(const uint8_t* r_ptr,
|
static int ImportYUVAFromRGBA(const uint8_t* r_ptr,
|
||||||
const uint8_t* g_ptr,
|
const uint8_t* g_ptr,
|
||||||
const uint8_t* b_ptr,
|
const uint8_t* b_ptr,
|
||||||
@ -518,7 +505,7 @@ static int ImportYUVAFromRGBA(const uint8_t* r_ptr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (use_iterative_conversion) {
|
if (use_iterative_conversion) {
|
||||||
SafeInitSharpYuv();
|
SharpYuvInit(VP8GetCPUInfo);
|
||||||
if (!PreprocessARGB(r_ptr, g_ptr, b_ptr, step, rgb_stride, picture)) {
|
if (!PreprocessARGB(r_ptr, g_ptr, b_ptr, step, rgb_stride, picture)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user