mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-24 03:59:43 +00:00
swscale: K&R formatting cosmetics (part I)
This commit is contained in:
parent
72b95764d0
commit
89d94b2182
@ -19,8 +19,8 @@
|
||||
*/
|
||||
|
||||
#include "libavutil/avutil.h"
|
||||
#include "libavutil/pixfmt.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/pixfmt.h"
|
||||
#include "swscale.h"
|
||||
#include "swscale_internal.h"
|
||||
|
||||
|
@ -22,48 +22,58 @@
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "config.h"
|
||||
|
||||
#include "libavutil/bswap.h"
|
||||
#include "config.h"
|
||||
#include "rgb2rgb.h"
|
||||
#include "swscale.h"
|
||||
#include "swscale_internal.h"
|
||||
|
||||
void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
|
||||
void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
|
||||
void (*rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
void (*rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
|
||||
void (*shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size);
|
||||
|
||||
void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
const uint8_t *vsrc, uint8_t *dst,
|
||||
int width, int height,
|
||||
int lumStride, int chromStride, int dstStride);
|
||||
void (*yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
|
||||
void (*yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
const uint8_t *vsrc, uint8_t *dst,
|
||||
int width, int height,
|
||||
int lumStride, int chromStride, int dstStride);
|
||||
void (*yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
|
||||
void (*yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
const uint8_t *vsrc, uint8_t *dst,
|
||||
int width, int height,
|
||||
int lumStride, int chromStride, int dstStride);
|
||||
void (*yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
|
||||
void (*yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
const uint8_t *vsrc, uint8_t *dst,
|
||||
int width, int height,
|
||||
int lumStride, int chromStride, int dstStride);
|
||||
void (*yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
|
||||
void (*yuy2toyv12)(const uint8_t *src, uint8_t *ydst,
|
||||
uint8_t *udst, uint8_t *vdst,
|
||||
int width, int height,
|
||||
int lumStride, int chromStride, int srcStride);
|
||||
void (*rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
|
||||
void (*rgb24toyv12)(const uint8_t *src, uint8_t *ydst,
|
||||
uint8_t *udst, uint8_t *vdst,
|
||||
int width, int height,
|
||||
int lumStride, int chromStride, int srcStride);
|
||||
void (*planar2x)(const uint8_t *src, uint8_t *dst, int width, int height,
|
||||
@ -76,22 +86,22 @@ void (*vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2,
|
||||
int width, int height,
|
||||
int srcStride1, int srcStride2,
|
||||
int dstStride1, int dstStride2);
|
||||
void (*yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2, const uint8_t *src3,
|
||||
uint8_t *dst,
|
||||
void (*yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2,
|
||||
const uint8_t *src3, uint8_t *dst,
|
||||
int width, int height,
|
||||
int srcStride1, int srcStride2,
|
||||
int srcStride3, int dstStride);
|
||||
void (*uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
|
||||
int width, int height,
|
||||
void (*uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
|
||||
const uint8_t *src, int width, int height,
|
||||
int lumStride, int chromStride, int srcStride);
|
||||
void (*uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
|
||||
int width, int height,
|
||||
void (*uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
|
||||
const uint8_t *src, int width, int height,
|
||||
int lumStride, int chromStride, int srcStride);
|
||||
void (*yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
|
||||
int width, int height,
|
||||
void (*yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
|
||||
const uint8_t *src, int width, int height,
|
||||
int lumStride, int chromStride, int srcStride);
|
||||
void (*yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
|
||||
int width, int height,
|
||||
void (*yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
|
||||
const uint8_t *src, int width, int height,
|
||||
int lumStride, int chromStride, int srcStride);
|
||||
|
||||
#define RGB2YUV_SHIFT 8
|
||||
@ -108,12 +118,11 @@ void (*yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t
|
||||
//plain C versions
|
||||
#include "rgb2rgb_template.c"
|
||||
|
||||
|
||||
/*
|
||||
RGB15->RGB16 original by Strepto/Astral
|
||||
ported to gcc & bugfixed : A'rpi
|
||||
MMX2, 3DNOW optimization by Nick Kurshev
|
||||
32-bit C version, and and&add trick by Michael Niedermayer
|
||||
* RGB15->RGB16 original by Strepto/Astral
|
||||
* ported to gcc & bugfixed : A'rpi
|
||||
* MMX2, 3DNOW optimization by Nick Kurshev
|
||||
* 32-bit C version, and and&add trick by Michael Niedermayer
|
||||
*/
|
||||
|
||||
void sws_rgb2rgb_init(void)
|
||||
@ -144,6 +153,7 @@ void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
void rgb24to32(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; 3 * i < src_size; i++) {
|
||||
#if HAVE_BIGENDIAN
|
||||
/* RGB24 (= R, G, B) -> BGR32 (= A, R, G, B) */
|
||||
@ -184,9 +194,9 @@ void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
|
||||
void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
{
|
||||
uint16_t rgb, r, g, b;
|
||||
uint16_t *d = (uint16_t *)dst;
|
||||
const uint16_t *s = (const uint16_t *)src;
|
||||
uint16_t rgb, r, g, b;
|
||||
const uint16_t *end = s + src_size / 2;
|
||||
|
||||
while (s < end) {
|
||||
@ -318,7 +328,8 @@ void bgr8torgb8(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
}
|
||||
|
||||
#define DEFINE_SHUFFLE_BYTES(a, b, c, d) \
|
||||
void shuffle_bytes_##a##b##c##d(const uint8_t *src, uint8_t *dst, int src_size) \
|
||||
void shuffle_bytes_ ## a ## b ## c ## d(const uint8_t *src, \
|
||||
uint8_t *dst, int src_size) \
|
||||
{ \
|
||||
int i; \
|
||||
\
|
||||
|
@ -26,7 +26,8 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
static inline void rgb24tobgr32_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
static inline void rgb24tobgr32_c(const uint8_t *src, uint8_t *dst,
|
||||
int src_size)
|
||||
{
|
||||
uint8_t *dest = dst;
|
||||
const uint8_t *s = src;
|
||||
@ -49,7 +50,8 @@ static inline void rgb24tobgr32_c(const uint8_t *src, uint8_t *dst, int src_size
|
||||
}
|
||||
}
|
||||
|
||||
static inline void rgb32tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
static inline void rgb32tobgr24_c(const uint8_t *src, uint8_t *dst,
|
||||
int src_size)
|
||||
{
|
||||
uint8_t *dest = dst;
|
||||
const uint8_t *s = src;
|
||||
@ -73,15 +75,15 @@ static inline void rgb32tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size
|
||||
}
|
||||
|
||||
/*
|
||||
original by Strepto/Astral
|
||||
ported to gcc & bugfixed: A'rpi
|
||||
MMX2, 3DNOW optimization by Nick Kurshev
|
||||
32-bit C version, and and&add trick by Michael Niedermayer
|
||||
* original by Strepto/Astral
|
||||
* ported to gcc & bugfixed: A'rpi
|
||||
* MMX2, 3DNOW optimization by Nick Kurshev
|
||||
* 32-bit C version, and and&add trick by Michael Niedermayer
|
||||
*/
|
||||
static inline void rgb15to16_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
{
|
||||
register const uint8_t* s=src;
|
||||
register uint8_t *d = dst;
|
||||
register const uint8_t *s = src;
|
||||
register const uint8_t *end = s + src_size;
|
||||
const uint8_t *mm_end = end - 3;
|
||||
|
||||
@ -99,8 +101,8 @@ static inline void rgb15to16_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
|
||||
static inline void rgb16to15_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
{
|
||||
register const uint8_t* s=src;
|
||||
register uint8_t *d = dst;
|
||||
register const uint8_t *s = src;
|
||||
register const uint8_t *end = s + src_size;
|
||||
const uint8_t *mm_end = end - 3;
|
||||
|
||||
@ -118,56 +120,71 @@ static inline void rgb16to15_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
|
||||
static inline void rgb32to16_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
{
|
||||
const uint8_t *s = src;
|
||||
uint16_t *d = (uint16_t *)dst;
|
||||
const uint8_t *s = src;
|
||||
const uint8_t *end = s + src_size;
|
||||
|
||||
while (s < end) {
|
||||
register int rgb = *(const uint32_t*)s; s += 4;
|
||||
*d++ = ((rgb&0xFF)>>3) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>8);
|
||||
register int rgb = *(const uint32_t *)s;
|
||||
s += 4;
|
||||
*d++ = ((rgb & 0xFF) >> 3) +
|
||||
((rgb & 0xFC00) >> 5) +
|
||||
((rgb & 0xF80000) >> 8);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void rgb32tobgr16_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
static inline void rgb32tobgr16_c(const uint8_t *src, uint8_t *dst,
|
||||
int src_size)
|
||||
{
|
||||
const uint8_t *s = src;
|
||||
uint16_t *d = (uint16_t *)dst;
|
||||
const uint8_t *s = src;
|
||||
const uint8_t *end = s + src_size;
|
||||
|
||||
while (s < end) {
|
||||
register int rgb = *(const uint32_t*)s; s += 4;
|
||||
*d++ = ((rgb&0xF8)<<8) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>19);
|
||||
register int rgb = *(const uint32_t *)s;
|
||||
s += 4;
|
||||
*d++ = ((rgb & 0xF8) << 8) +
|
||||
((rgb & 0xFC00) >> 5) +
|
||||
((rgb & 0xF80000) >> 19);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void rgb32to15_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
{
|
||||
const uint8_t *s = src;
|
||||
uint16_t *d = (uint16_t *)dst;
|
||||
const uint8_t *s = src;
|
||||
const uint8_t *end = s + src_size;
|
||||
|
||||
while (s < end) {
|
||||
register int rgb = *(const uint32_t*)s; s += 4;
|
||||
*d++ = ((rgb&0xFF)>>3) + ((rgb&0xF800)>>6) + ((rgb&0xF80000)>>9);
|
||||
register int rgb = *(const uint32_t *)s;
|
||||
s += 4;
|
||||
*d++ = ((rgb & 0xFF) >> 3) +
|
||||
((rgb & 0xF800) >> 6) +
|
||||
((rgb & 0xF80000) >> 9);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void rgb32tobgr15_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
static inline void rgb32tobgr15_c(const uint8_t *src, uint8_t *dst,
|
||||
int src_size)
|
||||
{
|
||||
const uint8_t *s = src;
|
||||
uint16_t *d = (uint16_t *)dst;
|
||||
const uint8_t *s = src;
|
||||
const uint8_t *end = s + src_size;
|
||||
|
||||
while (s < end) {
|
||||
register int rgb = *(const uint32_t*)s; s += 4;
|
||||
*d++ = ((rgb&0xF8)<<7) + ((rgb&0xF800)>>6) + ((rgb&0xF80000)>>19);
|
||||
register int rgb = *(const uint32_t *)s;
|
||||
s += 4;
|
||||
*d++ = ((rgb & 0xF8) << 7) +
|
||||
((rgb & 0xF800) >> 6) +
|
||||
((rgb & 0xF80000) >> 19);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void rgb24tobgr16_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
static inline void rgb24tobgr16_c(const uint8_t *src, uint8_t *dst,
|
||||
int src_size)
|
||||
{
|
||||
const uint8_t *s = src;
|
||||
uint16_t *d = (uint16_t *)dst;
|
||||
const uint8_t *s = src;
|
||||
const uint8_t *end = s + src_size;
|
||||
|
||||
while (s < end) {
|
||||
@ -180,8 +197,8 @@ static inline void rgb24tobgr16_c(const uint8_t *src, uint8_t *dst, int src_size
|
||||
|
||||
static inline void rgb24to16_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
{
|
||||
const uint8_t *s = src;
|
||||
uint16_t *d = (uint16_t *)dst;
|
||||
const uint8_t *s = src;
|
||||
const uint8_t *end = s + src_size;
|
||||
|
||||
while (s < end) {
|
||||
@ -192,10 +209,11 @@ static inline void rgb24to16_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void rgb24tobgr15_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
static inline void rgb24tobgr15_c(const uint8_t *src, uint8_t *dst,
|
||||
int src_size)
|
||||
{
|
||||
const uint8_t *s = src;
|
||||
uint16_t *d = (uint16_t *)dst;
|
||||
const uint8_t *s = src;
|
||||
const uint8_t *end = s + src_size;
|
||||
|
||||
while (s < end) {
|
||||
@ -208,8 +226,8 @@ static inline void rgb24tobgr15_c(const uint8_t *src, uint8_t *dst, int src_size
|
||||
|
||||
static inline void rgb24to15_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
{
|
||||
const uint8_t *s = src;
|
||||
uint16_t *d = (uint16_t *)dst;
|
||||
const uint8_t *s = src;
|
||||
const uint8_t *end = s + src_size;
|
||||
|
||||
while (s < end) {
|
||||
@ -221,27 +239,28 @@ static inline void rgb24to15_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
}
|
||||
|
||||
/*
|
||||
I use less accurate approximation here by simply left-shifting the input
|
||||
value and filling the low order bits with zeroes. This method improves PNG
|
||||
compression but this scheme cannot reproduce white exactly, since it does
|
||||
not generate an all-ones maximum value; the net effect is to darken the
|
||||
image slightly.
|
||||
|
||||
The better method should be "left bit replication":
|
||||
|
||||
4 3 2 1 0
|
||||
---------
|
||||
1 1 0 1 1
|
||||
|
||||
7 6 5 4 3 2 1 0
|
||||
----------------
|
||||
1 1 0 1 1 1 1 0
|
||||
|=======| |===|
|
||||
| leftmost bits repeated to fill open bits
|
||||
|
|
||||
original bits
|
||||
* I use less accurate approximation here by simply left-shifting the input
|
||||
* value and filling the low order bits with zeroes. This method improves PNG
|
||||
* compression but this scheme cannot reproduce white exactly, since it does
|
||||
* not generate an all-ones maximum value; the net effect is to darken the
|
||||
* image slightly.
|
||||
*
|
||||
* The better method should be "left bit replication":
|
||||
*
|
||||
* 4 3 2 1 0
|
||||
* ---------
|
||||
* 1 1 0 1 1
|
||||
*
|
||||
* 7 6 5 4 3 2 1 0
|
||||
* ----------------
|
||||
* 1 1 0 1 1 1 1 0
|
||||
* |=======| |===|
|
||||
* | leftmost bits repeated to fill open bits
|
||||
* |
|
||||
* original bits
|
||||
*/
|
||||
static inline void rgb15tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
static inline void rgb15tobgr24_c(const uint8_t *src, uint8_t *dst,
|
||||
int src_size)
|
||||
{
|
||||
uint8_t *d = dst;
|
||||
const uint16_t *s = (const uint16_t *)src;
|
||||
@ -255,7 +274,8 @@ static inline void rgb15tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size
|
||||
}
|
||||
}
|
||||
|
||||
static inline void rgb16tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
static inline void rgb16tobgr24_c(const uint8_t *src, uint8_t *dst,
|
||||
int src_size)
|
||||
{
|
||||
uint8_t *d = (uint8_t *)dst;
|
||||
const uint16_t *s = (const uint16_t *)src;
|
||||
@ -313,11 +333,13 @@ static inline void rgb16to32_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void shuffle_bytes_2103_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
static inline void shuffle_bytes_2103_c(const uint8_t *src, uint8_t *dst,
|
||||
int src_size)
|
||||
{
|
||||
int idx = 15 - src_size;
|
||||
const uint8_t *s = src - idx;
|
||||
uint8_t *d = dst - idx;
|
||||
|
||||
for (; idx < 15; idx += 4) {
|
||||
register int v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00;
|
||||
v &= 0xff00ff;
|
||||
@ -328,6 +350,7 @@ static inline void shuffle_bytes_2103_c(const uint8_t *src, uint8_t *dst, int sr
|
||||
static inline void rgb24tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < src_size; i += 3) {
|
||||
register uint8_t x = src[i + 2];
|
||||
dst[i + 1] = src[i + 1];
|
||||
@ -344,6 +367,7 @@ static inline void yuvPlanartoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
{
|
||||
int y, i;
|
||||
const int chromWidth = width >> 1;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
#if HAVE_FAST_64BIT
|
||||
uint64_t *ldst = (uint64_t *)dst;
|
||||
@ -362,6 +386,7 @@ static inline void yuvPlanartoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
#else
|
||||
int *idst = (int32_t *)dst;
|
||||
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
|
||||
|
||||
for (i = 0; i < chromWidth; i++) {
|
||||
#if HAVE_BIGENDIAN
|
||||
*idst++ = (yc[0] << 24) + (uc[0] << 16) +
|
||||
@ -390,9 +415,8 @@ static inline void yuvPlanartoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
*/
|
||||
static inline void yv12toyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
const uint8_t *vsrc, uint8_t *dst,
|
||||
int width, int height,
|
||||
int lumStride, int chromStride,
|
||||
int dstStride)
|
||||
int width, int height, int lumStride,
|
||||
int chromStride, int dstStride)
|
||||
{
|
||||
//FIXME interpolate chroma
|
||||
yuvPlanartoyuy2_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
|
||||
@ -407,6 +431,7 @@ static inline void yuvPlanartouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
{
|
||||
int y, i;
|
||||
const int chromWidth = width >> 1;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
#if HAVE_FAST_64BIT
|
||||
uint64_t *ldst = (uint64_t *)dst;
|
||||
@ -425,6 +450,7 @@ static inline void yuvPlanartouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
#else
|
||||
int *idst = (int32_t *)dst;
|
||||
const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
|
||||
|
||||
for (i = 0; i < chromWidth; i++) {
|
||||
#if HAVE_BIGENDIAN
|
||||
*idst++ = (uc[0] << 24) + (yc[0] << 16) +
|
||||
@ -453,9 +479,8 @@ static inline void yuvPlanartouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
*/
|
||||
static inline void yv12touyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
const uint8_t *vsrc, uint8_t *dst,
|
||||
int width, int height,
|
||||
int lumStride, int chromStride,
|
||||
int dstStride)
|
||||
int width, int height, int lumStride,
|
||||
int chromStride, int dstStride)
|
||||
{
|
||||
//FIXME interpolate chroma
|
||||
yuvPlanartouyvy_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
|
||||
@ -467,9 +492,8 @@ static inline void yv12touyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
*/
|
||||
static inline void yuv422ptouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
const uint8_t *vsrc, uint8_t *dst,
|
||||
int width, int height,
|
||||
int lumStride, int chromStride,
|
||||
int dstStride)
|
||||
int width, int height, int lumStride,
|
||||
int chromStride, int dstStride)
|
||||
{
|
||||
yuvPlanartouyvy_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
|
||||
chromStride, dstStride, 1);
|
||||
@ -480,9 +504,8 @@ static inline void yuv422ptouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
*/
|
||||
static inline void yuv422ptoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
const uint8_t *vsrc, uint8_t *dst,
|
||||
int width, int height,
|
||||
int lumStride, int chromStride,
|
||||
int dstStride)
|
||||
int width, int height, int lumStride,
|
||||
int chromStride, int dstStride)
|
||||
{
|
||||
yuvPlanartoyuy2_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
|
||||
chromStride, dstStride, 1);
|
||||
@ -494,12 +517,12 @@ static inline void yuv422ptoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
|
||||
*/
|
||||
static inline void yuy2toyv12_c(const uint8_t *src, uint8_t *ydst,
|
||||
uint8_t *udst, uint8_t *vdst,
|
||||
int width, int height,
|
||||
int lumStride, int chromStride,
|
||||
int srcStride)
|
||||
int width, int height, int lumStride,
|
||||
int chromStride, int srcStride)
|
||||
{
|
||||
int y;
|
||||
const int chromWidth = width >> 1;
|
||||
|
||||
for (y = 0; y < height; y += 2) {
|
||||
int i;
|
||||
for (i = 0; i < chromWidth; i++) {
|
||||
@ -541,16 +564,16 @@ static inline void planar2x_c(const uint8_t *src, uint8_t *dst, int srcWidth,
|
||||
for (y = 1; y < srcHeight; y++) {
|
||||
const int mmxSize = 1;
|
||||
|
||||
dst[0 ]= (3*src[0] + src[srcStride])>>2;
|
||||
dst[0] = (src[0] * 3 + src[srcStride]) >> 2;
|
||||
dst[dstStride] = (src[0] + 3 * src[srcStride]) >> 2;
|
||||
|
||||
for (x = mmxSize - 1; x < srcWidth - 1; x++) {
|
||||
dst[2*x +1]= (3*src[x+0] + src[x+srcStride+1])>>2;
|
||||
dst[2 * x + 1] = (src[x + 0] * 3 + src[x + srcStride + 1]) >> 2;
|
||||
dst[2 * x + dstStride + 2] = (src[x + 0] + 3 * src[x + srcStride + 1]) >> 2;
|
||||
dst[2 * x + dstStride + 1] = (src[x + 1] + 3 * src[x + srcStride]) >> 2;
|
||||
dst[2*x +2]= (3*src[x+1] + src[x+srcStride ])>>2;
|
||||
dst[2 * x + 2] = (src[x + 1] * 3 + src[x + srcStride]) >> 2;
|
||||
}
|
||||
dst[srcWidth*2 -1 ]= (3*src[srcWidth-1] + src[srcWidth-1 + srcStride])>>2;
|
||||
dst[srcWidth * 2 - 1] = (src[srcWidth - 1] * 3 + src[srcWidth - 1 + srcStride]) >> 2;
|
||||
dst[srcWidth * 2 - 1 + dstStride] = (src[srcWidth - 1] + 3 * src[srcWidth - 1 + srcStride]) >> 2;
|
||||
|
||||
dst += dstStride * 2;
|
||||
@ -561,7 +584,7 @@ static inline void planar2x_c(const uint8_t *src, uint8_t *dst, int srcWidth,
|
||||
dst[0] = src[0];
|
||||
|
||||
for (x = 0; x < srcWidth - 1; x++) {
|
||||
dst[2*x+1]= (3*src[x] + src[x+1])>>2;
|
||||
dst[2 * x + 1] = (src[x] * 3 + src[x + 1]) >> 2;
|
||||
dst[2 * x + 2] = (src[x] + 3 * src[x + 1]) >> 2;
|
||||
}
|
||||
dst[2 * srcWidth - 1] = src[srcWidth - 1];
|
||||
@ -575,12 +598,12 @@ static inline void planar2x_c(const uint8_t *src, uint8_t *dst, int srcWidth,
|
||||
*/
|
||||
static inline void uyvytoyv12_c(const uint8_t *src, uint8_t *ydst,
|
||||
uint8_t *udst, uint8_t *vdst,
|
||||
int width, int height,
|
||||
int lumStride, int chromStride,
|
||||
int srcStride)
|
||||
int width, int height, int lumStride,
|
||||
int chromStride, int srcStride)
|
||||
{
|
||||
int y;
|
||||
const int chromWidth = width >> 1;
|
||||
|
||||
for (y = 0; y < height; y += 2) {
|
||||
int i;
|
||||
for (i = 0; i < chromWidth; i++) {
|
||||
@ -666,9 +689,8 @@ void rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
|
||||
}
|
||||
|
||||
static void interleaveBytes_c(const uint8_t *src1, const uint8_t *src2,
|
||||
uint8_t *dest, int width,
|
||||
int height, int src1Stride,
|
||||
int src2Stride, int dstStride)
|
||||
uint8_t *dest, int width, int height,
|
||||
int src1Stride, int src2Stride, int dstStride)
|
||||
{
|
||||
int h;
|
||||
|
||||
@ -740,9 +762,8 @@ static inline void yvu9_to_yuy2_c(const uint8_t *src1, const uint8_t *src2,
|
||||
static void extract_even_c(const uint8_t *src, uint8_t *dst, int count)
|
||||
{
|
||||
dst += count;
|
||||
src += 2*count;
|
||||
src += count * 2;
|
||||
count = -count;
|
||||
|
||||
while (count < 0) {
|
||||
dst[count] = src[2 * count];
|
||||
count++;
|
||||
@ -754,7 +775,7 @@ static void extract_even2_c(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
|
||||
{
|
||||
dst0 += count;
|
||||
dst1 += count;
|
||||
src += 4*count;
|
||||
src += count * 4;
|
||||
count = -count;
|
||||
while (count < 0) {
|
||||
dst0[count] = src[4 * count + 0];
|
||||
@ -768,8 +789,8 @@ static void extract_even2avg_c(const uint8_t *src0, const uint8_t *src1,
|
||||
{
|
||||
dst0 += count;
|
||||
dst1 += count;
|
||||
src0 += 4*count;
|
||||
src1 += 4*count;
|
||||
src0 += count * 4;
|
||||
src1 += count * 4;
|
||||
count = -count;
|
||||
while (count < 0) {
|
||||
dst0[count] = (src0[4 * count + 0] + src1[4 * count + 0]) >> 1;
|
||||
@ -783,7 +804,7 @@ static void extract_odd2_c(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
|
||||
{
|
||||
dst0 += count;
|
||||
dst1 += count;
|
||||
src += 4*count;
|
||||
src += count * 4;
|
||||
count = -count;
|
||||
src++;
|
||||
while (count < 0) {
|
||||
@ -798,8 +819,8 @@ static void extract_odd2avg_c(const uint8_t *src0, const uint8_t *src1,
|
||||
{
|
||||
dst0 += count;
|
||||
dst1 += count;
|
||||
src0 += 4*count;
|
||||
src1 += 4*count;
|
||||
src0 += count * 4;
|
||||
src1 += count * 4;
|
||||
count = -count;
|
||||
src0++;
|
||||
src1++;
|
||||
|
@ -28,12 +28,12 @@
|
||||
#include <inttypes.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/bswap.h"
|
||||
#include "config.h"
|
||||
#include "rgb2rgb.h"
|
||||
#include "swscale.h"
|
||||
#include "swscale_internal.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/bswap.h"
|
||||
|
||||
extern const uint8_t dither_4x4_16[4][8];
|
||||
extern const uint8_t dither_8x8_32[8][8];
|
||||
@ -73,15 +73,23 @@ const int *sws_getCoefficients(int colorspace)
|
||||
|
||||
#define PUTRGB24(dst, src, i) \
|
||||
Y = src[2 * i]; \
|
||||
dst[6*i+0] = r[Y]; dst[6*i+1] = g[Y]; dst[6*i+2] = b[Y]; \
|
||||
dst[6 * i + 0] = r[Y]; \
|
||||
dst[6 * i + 1] = g[Y]; \
|
||||
dst[6 * i + 2] = b[Y]; \
|
||||
Y = src[2 * i + 1]; \
|
||||
dst[6*i+3] = r[Y]; dst[6*i+4] = g[Y]; dst[6*i+5] = b[Y];
|
||||
dst[6 * i + 3] = r[Y]; \
|
||||
dst[6 * i + 4] = g[Y]; \
|
||||
dst[6 * i + 5] = b[Y];
|
||||
|
||||
#define PUTBGR24(dst, src, i) \
|
||||
Y = src[2 * i]; \
|
||||
dst[6*i+0] = b[Y]; dst[6*i+1] = g[Y]; dst[6*i+2] = r[Y]; \
|
||||
dst[6 * i + 0] = b[Y]; \
|
||||
dst[6 * i + 1] = g[Y]; \
|
||||
dst[6 * i + 2] = r[Y]; \
|
||||
Y = src[2 * i + 1]; \
|
||||
dst[6*i+3] = b[Y]; dst[6*i+4] = g[Y]; dst[6*i+5] = r[Y];
|
||||
dst[6 * i + 3] = b[Y]; \
|
||||
dst[6 * i + 4] = g[Y]; \
|
||||
dst[6 * i + 5] = r[Y];
|
||||
|
||||
#define PUTRGBA(dst, ysrc, asrc, i, s) \
|
||||
Y = ysrc[2 * i]; \
|
||||
@ -110,8 +118,9 @@ const int *sws_getCoefficients(int colorspace)
|
||||
dst[12 * i + 10] = dst[12 * i + 11] = r[Y];
|
||||
|
||||
#define YUV2RGBFUNC(func_name, dst_type, alpha) \
|
||||
static int func_name(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY, \
|
||||
int srcSliceH, uint8_t* dst[], int dstStride[]) \
|
||||
static int func_name(SwsContext *c, const uint8_t *src[], \
|
||||
int srcStride[], int srcSliceY, int srcSliceH, \
|
||||
uint8_t *dst[], int dstStride[]) \
|
||||
{ \
|
||||
int y; \
|
||||
\
|
||||
@ -120,10 +129,11 @@ static int func_name(SwsContext *c, const uint8_t* src[], int srcStride[], int s
|
||||
srcStride[2] *= 2; \
|
||||
} \
|
||||
for (y = 0; y < srcSliceH; y += 2) { \
|
||||
dst_type *dst_1 = (dst_type*)(dst[0] + (y+srcSliceY )*dstStride[0]);\
|
||||
dst_type *dst_2 = (dst_type*)(dst[0] + (y+srcSliceY+1)*dstStride[0]);\
|
||||
dst_type av_unused *r, *b;\
|
||||
dst_type *g;\
|
||||
dst_type *dst_1 = \
|
||||
(dst_type *)(dst[0] + (y + srcSliceY) * dstStride[0]); \
|
||||
dst_type *dst_2 = \
|
||||
(dst_type *)(dst[0] + (y + srcSliceY + 1) * dstStride[0]); \
|
||||
dst_type av_unused *r, *g, *b; \
|
||||
const uint8_t *py_1 = src[0] + y * srcStride[0]; \
|
||||
const uint8_t *py_2 = py_1 + srcStride[0]; \
|
||||
const uint8_t *pu = src[1] + (y >> 1) * srcStride[1]; \
|
||||
@ -135,8 +145,7 @@ static int func_name(SwsContext *c, const uint8_t* src[], int srcStride[], int s
|
||||
pa_2 = pa_1 + srcStride[3]; \
|
||||
} \
|
||||
while (h_size--) { \
|
||||
int av_unused U, V;\
|
||||
int Y;\
|
||||
int av_unused U, V, Y; \
|
||||
|
||||
#define ENDYUV2RGBLINE(dst_delta) \
|
||||
pu += 4; \
|
||||
@ -369,11 +378,16 @@ CLOSEYUV2RGBFUNC(8)
|
||||
// r, g, b, dst_1, dst_2
|
||||
YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0)
|
||||
const uint8_t *d16 = dither_4x4_16[y & 3];
|
||||
|
||||
#define PUTRGB12(dst, src, i, o) \
|
||||
Y = src[2 * i]; \
|
||||
dst[2*i] = r[Y+d16[0+o]] + g[Y+d16[0+o]] + b[Y+d16[0+o]]; \
|
||||
dst[2 * i] = r[Y + d16[0 + o]] + \
|
||||
g[Y + d16[0 + o]] + \
|
||||
b[Y + d16[0 + o]]; \
|
||||
Y = src[2 * i + 1]; \
|
||||
dst[2*i+1] = r[Y+d16[1+o]] + g[Y+d16[1+o]] + b[Y+d16[1+o]];
|
||||
dst[2 * i + 1] = r[Y + d16[1 + o]] + \
|
||||
g[Y + d16[1 + o]] + \
|
||||
b[Y + d16[1 + o]];
|
||||
|
||||
LOADCHROMA(0);
|
||||
PUTRGB12(dst_1, py_1, 0, 0);
|
||||
@ -396,11 +410,16 @@ CLOSEYUV2RGBFUNC(8)
|
||||
YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
|
||||
const uint8_t *d32 = dither_8x8_32[y & 7];
|
||||
const uint8_t *d64 = dither_8x8_73[y & 7];
|
||||
|
||||
#define PUTRGB8(dst, src, i, o) \
|
||||
Y = src[2 * i]; \
|
||||
dst[2*i] = r[Y+d32[0+o]] + g[Y+d32[0+o]] + b[Y+d64[0+o]]; \
|
||||
dst[2 * i] = r[Y + d32[0 + o]] + \
|
||||
g[Y + d32[0 + o]] + \
|
||||
b[Y + d64[0 + o]]; \
|
||||
Y = src[2 * i + 1]; \
|
||||
dst[2*i+1] = r[Y+d32[1+o]] + g[Y+d32[1+o]] + b[Y+d64[1+o]];
|
||||
dst[2 * i + 1] = r[Y + d32[1 + o]] + \
|
||||
g[Y + d32[1 + o]] + \
|
||||
b[Y + d64[1 + o]];
|
||||
|
||||
LOADCHROMA(0);
|
||||
PUTRGB8(dst_1, py_1, 0, 0);
|
||||
@ -426,9 +445,13 @@ YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0)
|
||||
|
||||
#define PUTRGB4D(dst, src, i, o) \
|
||||
Y = src[2 * i]; \
|
||||
acc = r[Y+d128[0+o]] + g[Y+d64[0+o]] + b[Y+d128[0+o]]; \
|
||||
acc = r[Y + d128[0 + o]] + \
|
||||
g[Y + d64[0 + o]] + \
|
||||
b[Y + d128[0 + o]]; \
|
||||
Y = src[2 * i + 1]; \
|
||||
acc |= (r[Y+d128[1+o]] + g[Y+d64[1+o]] + b[Y+d128[1+o]])<<4; \
|
||||
acc |= (r[Y + d128[1 + o]] + \
|
||||
g[Y + d64[1 + o]] + \
|
||||
b[Y + d128[1 + o]]) << 4; \
|
||||
dst[i] = acc;
|
||||
|
||||
LOADCHROMA(0);
|
||||
@ -454,9 +477,13 @@ YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
|
||||
|
||||
#define PUTRGB4DB(dst, src, i, o) \
|
||||
Y = src[2 * i]; \
|
||||
dst[2*i] = r[Y+d128[0+o]] + g[Y+d64[0+o]] + b[Y+d128[0+o]]; \
|
||||
dst[2 * i] = r[Y + d128[0 + o]] + \
|
||||
g[Y + d64[0 + o]] + \
|
||||
b[Y + d128[0 + o]]; \
|
||||
Y = src[2 * i + 1]; \
|
||||
dst[2*i+1] = r[Y+d128[1+o]] + g[Y+d64[1+o]] + b[Y+d128[1+o]];
|
||||
dst[2 * i + 1] = r[Y + d128[1 + o]] + \
|
||||
g[Y + d64[1 + o]] + \
|
||||
b[Y + d128[1 + o]];
|
||||
|
||||
LOADCHROMA(0);
|
||||
PUTRGB4DB(dst_1, py_1, 0, 0);
|
||||
@ -506,52 +533,70 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
|
||||
{
|
||||
SwsFunc t = NULL;
|
||||
|
||||
if (HAVE_MMX) {
|
||||
if (HAVE_MMX)
|
||||
t = ff_yuv2rgb_init_mmx(c);
|
||||
} else if (HAVE_VIS) {
|
||||
else if (HAVE_VIS)
|
||||
t = ff_yuv2rgb_init_vis(c);
|
||||
} else if (HAVE_ALTIVEC) {
|
||||
else if (HAVE_ALTIVEC)
|
||||
t = ff_yuv2rgb_init_altivec(c);
|
||||
} else if (ARCH_BFIN) {
|
||||
else if (ARCH_BFIN)
|
||||
t = ff_yuv2rgb_get_func_ptr_bfin(c);
|
||||
}
|
||||
|
||||
if (t)
|
||||
return t;
|
||||
|
||||
av_log(c, AV_LOG_WARNING, "No accelerated colorspace conversion found from %s to %s.\n", sws_format_name(c->srcFormat), sws_format_name(c->dstFormat));
|
||||
av_log(c, AV_LOG_WARNING,
|
||||
"No accelerated colorspace conversion found from %s to %s.\n",
|
||||
sws_format_name(c->srcFormat), sws_format_name(c->dstFormat));
|
||||
|
||||
switch (c->dstFormat) {
|
||||
case PIX_FMT_BGR48BE:
|
||||
case PIX_FMT_BGR48LE: return yuv2rgb_c_bgr48;
|
||||
case PIX_FMT_BGR48LE:
|
||||
return yuv2rgb_c_bgr48;
|
||||
case PIX_FMT_RGB48BE:
|
||||
case PIX_FMT_RGB48LE: return yuv2rgb_c_48;
|
||||
case PIX_FMT_RGB48LE:
|
||||
return yuv2rgb_c_48;
|
||||
case PIX_FMT_ARGB:
|
||||
case PIX_FMT_ABGR: if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) return yuva2argb_c;
|
||||
case PIX_FMT_ABGR:
|
||||
if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P)
|
||||
return yuva2argb_c;
|
||||
case PIX_FMT_RGBA:
|
||||
case PIX_FMT_BGRA: return (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) ? yuva2rgba_c : yuv2rgb_c_32;
|
||||
case PIX_FMT_RGB24: return yuv2rgb_c_24_rgb;
|
||||
case PIX_FMT_BGR24: return yuv2rgb_c_24_bgr;
|
||||
case PIX_FMT_BGRA:
|
||||
if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P)
|
||||
return yuva2rgba_c;
|
||||
else
|
||||
return yuv2rgb_c_32;
|
||||
case PIX_FMT_RGB24:
|
||||
return yuv2rgb_c_24_rgb;
|
||||
case PIX_FMT_BGR24:
|
||||
return yuv2rgb_c_24_bgr;
|
||||
case PIX_FMT_RGB565:
|
||||
case PIX_FMT_BGR565:
|
||||
case PIX_FMT_RGB555:
|
||||
case PIX_FMT_BGR555: return yuv2rgb_c_16;
|
||||
case PIX_FMT_BGR555:
|
||||
return yuv2rgb_c_16;
|
||||
case PIX_FMT_RGB444:
|
||||
case PIX_FMT_BGR444: return yuv2rgb_c_12_ordered_dither;
|
||||
case PIX_FMT_BGR444:
|
||||
return yuv2rgb_c_12_ordered_dither;
|
||||
case PIX_FMT_RGB8:
|
||||
case PIX_FMT_BGR8: return yuv2rgb_c_8_ordered_dither;
|
||||
case PIX_FMT_BGR8:
|
||||
return yuv2rgb_c_8_ordered_dither;
|
||||
case PIX_FMT_RGB4:
|
||||
case PIX_FMT_BGR4: return yuv2rgb_c_4_ordered_dither;
|
||||
case PIX_FMT_BGR4:
|
||||
return yuv2rgb_c_4_ordered_dither;
|
||||
case PIX_FMT_RGB4_BYTE:
|
||||
case PIX_FMT_BGR4_BYTE: return yuv2rgb_c_4b_ordered_dither;
|
||||
case PIX_FMT_MONOBLACK: return yuv2rgb_c_1_ordered_dither;
|
||||
case PIX_FMT_BGR4_BYTE:
|
||||
return yuv2rgb_c_4b_ordered_dither;
|
||||
case PIX_FMT_MONOBLACK:
|
||||
return yuv2rgb_c_1_ordered_dither;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void fill_table(uint8_t* table[256], const int elemsize, const int inc, void *y_tab)
|
||||
static void fill_table(uint8_t *table[256], const int elemsize,
|
||||
const int inc, void *y_tab)
|
||||
{
|
||||
int i;
|
||||
int64_t cb = 0;
|
||||
@ -580,33 +625,38 @@ static void fill_gv_table(int table[256], const int elemsize, const int inc)
|
||||
static uint16_t roundToInt16(int64_t f)
|
||||
{
|
||||
int r = (f + (1 << 15)) >> 16;
|
||||
if (r<-0x7FFF) return 0x8000;
|
||||
else if (r> 0x7FFF) return 0x7FFF;
|
||||
else return r;
|
||||
|
||||
if (r < -0x7FFF)
|
||||
return 0x8000;
|
||||
else if (r > 0x7FFF)
|
||||
return 0x7FFF;
|
||||
else
|
||||
return r;
|
||||
}
|
||||
|
||||
av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange,
|
||||
int brightness, int contrast, int saturation)
|
||||
av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
|
||||
int fullRange, int brightness,
|
||||
int contrast, int saturation)
|
||||
{
|
||||
const int isRgb = c->dstFormat==PIX_FMT_RGB32
|
||||
|| c->dstFormat==PIX_FMT_RGB32_1
|
||||
|| c->dstFormat==PIX_FMT_BGR24
|
||||
|| c->dstFormat==PIX_FMT_RGB565BE
|
||||
|| c->dstFormat==PIX_FMT_RGB565LE
|
||||
|| c->dstFormat==PIX_FMT_RGB555BE
|
||||
|| c->dstFormat==PIX_FMT_RGB555LE
|
||||
|| c->dstFormat==PIX_FMT_RGB444BE
|
||||
|| c->dstFormat==PIX_FMT_RGB444LE
|
||||
|| c->dstFormat==PIX_FMT_RGB8
|
||||
|| c->dstFormat==PIX_FMT_RGB4
|
||||
|| c->dstFormat==PIX_FMT_RGB4_BYTE
|
||||
|| c->dstFormat==PIX_FMT_MONOBLACK;
|
||||
const int isNotNe = c->dstFormat==PIX_FMT_NE(RGB565LE,RGB565BE)
|
||||
|| c->dstFormat==PIX_FMT_NE(RGB555LE,RGB555BE)
|
||||
|| c->dstFormat==PIX_FMT_NE(RGB444LE,RGB444BE)
|
||||
|| c->dstFormat==PIX_FMT_NE(BGR565LE,BGR565BE)
|
||||
|| c->dstFormat==PIX_FMT_NE(BGR555LE,BGR555BE)
|
||||
|| c->dstFormat==PIX_FMT_NE(BGR444LE,BGR444BE);
|
||||
const int isRgb = c->dstFormat == PIX_FMT_RGB32 ||
|
||||
c->dstFormat == PIX_FMT_RGB32_1 ||
|
||||
c->dstFormat == PIX_FMT_BGR24 ||
|
||||
c->dstFormat == PIX_FMT_RGB565BE ||
|
||||
c->dstFormat == PIX_FMT_RGB565LE ||
|
||||
c->dstFormat == PIX_FMT_RGB555BE ||
|
||||
c->dstFormat == PIX_FMT_RGB555LE ||
|
||||
c->dstFormat == PIX_FMT_RGB444BE ||
|
||||
c->dstFormat == PIX_FMT_RGB444LE ||
|
||||
c->dstFormat == PIX_FMT_RGB8 ||
|
||||
c->dstFormat == PIX_FMT_RGB4 ||
|
||||
c->dstFormat == PIX_FMT_RGB4_BYTE ||
|
||||
c->dstFormat == PIX_FMT_MONOBLACK;
|
||||
const int isNotNe = c->dstFormat == PIX_FMT_NE(RGB565LE, RGB565BE) ||
|
||||
c->dstFormat == PIX_FMT_NE(RGB555LE, RGB555BE) ||
|
||||
c->dstFormat == PIX_FMT_NE(RGB444LE, RGB444BE) ||
|
||||
c->dstFormat == PIX_FMT_NE(BGR565LE, BGR565BE) ||
|
||||
c->dstFormat == PIX_FMT_NE(BGR555LE, BGR555BE) ||
|
||||
c->dstFormat == PIX_FMT_NE(BGR444LE, BGR444BE);
|
||||
const int bpp = c->dstFormatBpp;
|
||||
uint8_t *y_table;
|
||||
uint16_t *y_table16;
|
||||
@ -620,7 +670,6 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int
|
||||
int64_t cgv = -inv_table[3];
|
||||
int64_t cy = 1 << 16;
|
||||
int64_t oy = 0;
|
||||
|
||||
int64_t yb = 0;
|
||||
|
||||
if (!fullRange) {
|
||||
@ -775,7 +824,8 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int
|
||||
fill_gv_table(c->table_gV, 1, cgv);
|
||||
break;
|
||||
case 32:
|
||||
base = (c->dstFormat == PIX_FMT_RGB32_1 || c->dstFormat == PIX_FMT_BGR32_1) ? 8 : 0;
|
||||
base = (c->dstFormat == PIX_FMT_RGB32_1 ||
|
||||
c->dstFormat == PIX_FMT_BGR32_1) ? 8 : 0;
|
||||
rbase = base + (isRgb ? 16 : 0);
|
||||
gbase = base + 8;
|
||||
bbase = base + (isRgb ? 0 : 16);
|
||||
@ -787,7 +837,8 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int
|
||||
yb = -(384 << 16) - oy;
|
||||
for (i = 0; i < 1024; i++) {
|
||||
unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
|
||||
y_table32[i ] = (yval << rbase) + (needAlpha ? 0 : (255u << abase));
|
||||
y_table32[i] = (yval << rbase) +
|
||||
(needAlpha ? 0 : (255u << abase));
|
||||
y_table32[i + 1024] = yval << gbase;
|
||||
y_table32[i + 2048] = yval << bbase;
|
||||
yb += cy;
|
||||
|
Loading…
Reference in New Issue
Block a user