Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
3d3c8149
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3d3c8149
编写于
6月 16, 2011
作者:
R
Ronald S. Bultje
提交者:
Ronald Bultje
6月 27, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
swscale: disentangle yuv2rgbX_c_full() into small functions.
This is part of the Great Evil Plan to simplify swscale.
上级
6fba14ee
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
171 addition
and
121 deletion
+171
-121
libswscale/swscale.c
libswscale/swscale.c
+171
-121
未找到文件。
libswscale/swscale.c
浏览文件 @
3d3c8149
...
...
@@ -1144,7 +1144,7 @@ yuv2rgb_1_c_template(SwsContext *c, const uint16_t *buf0,
}
}
#define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \
#define YUV2RGBWRAPPER
X
(name, base, ext, fmt, hasAlpha) \
static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
const int16_t **lumSrc, int lumFilterSize, \
const int16_t *chrFilter, const int16_t **chrUSrc, \
...
...
@@ -1155,8 +1155,9 @@ static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
alpSrc, dest, dstW, y, fmt, hasAlpha); \
} \
\
}
#define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \
YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
static void name ## ext ## _2_c(SwsContext *c, const uint16_t *buf0, \
const uint16_t *buf1, const uint16_t *ubuf0, \
const uint16_t *ubuf1, const uint16_t *vbuf0, \
...
...
@@ -1201,131 +1202,117 @@ YUV2RGBWRAPPER(yuv2rgb,, 8, PIX_FMT_RGB8, 0);
YUV2RGBWRAPPER
(
yuv2rgb
,,
4
,
PIX_FMT_RGB4
,
0
);
YUV2RGBWRAPPER
(
yuv2rgb
,,
4
b
,
PIX_FMT_RGB4_BYTE
,
0
);
#define YSCALE_YUV_2_RGBX_FULL_C(rnd,alpha) \
for (i=0; i<dstW; i++) {\
int j;\
int Y = 0;\
int U = -128<<19;\
int V = -128<<19;\
int av_unused A;\
int R,G,B;\
\
for (j=0; j<lumFilterSize; j++) {\
Y += lumSrc[j][i ] * lumFilter[j];\
}\
for (j=0; j<chrFilterSize; j++) {\
U += chrUSrc[j][i] * chrFilter[j];\
V += chrVSrc[j][i] * chrFilter[j];\
}\
Y >>=10;\
U >>=10;\
V >>=10;\
if (alpha) {\
A = rnd;\
for (j=0; j<lumFilterSize; j++)\
A += alpSrc[j][i ] * lumFilter[j];\
A >>=19;\
if (A&0x100)\
A = av_clip_uint8(A);\
}\
Y-= c->yuv2rgb_y_offset;\
Y*= c->yuv2rgb_y_coeff;\
Y+= rnd;\
R= Y + V*c->yuv2rgb_v2r_coeff;\
G= Y + V*c->yuv2rgb_v2g_coeff + U*c->yuv2rgb_u2g_coeff;\
B= Y + U*c->yuv2rgb_u2b_coeff;\
if ((R|G|B)&(0xC0000000)) {\
R = av_clip_uintp2(R, 30); \
G = av_clip_uintp2(G, 30); \
B = av_clip_uintp2(B, 30); \
}
static
void
yuv2rgbX_c_full
(
SwsContext
*
c
,
const
int16_t
*
lumFilter
,
const
int16_t
**
lumSrc
,
int
lumFilterSize
,
const
int16_t
*
chrFilter
,
const
int16_t
**
chrUSrc
,
const
int16_t
**
chrVSrc
,
int
chrFilterSize
,
const
int16_t
**
alpSrc
,
uint8_t
*
dest
,
int
dstW
,
int
y
)
static
av_always_inline
void
yuv2rgb_full_X_c_template
(
SwsContext
*
c
,
const
int16_t
*
lumFilter
,
const
int16_t
**
lumSrc
,
int
lumFilterSize
,
const
int16_t
*
chrFilter
,
const
int16_t
**
chrUSrc
,
const
int16_t
**
chrVSrc
,
int
chrFilterSize
,
const
int16_t
**
alpSrc
,
uint8_t
*
dest
,
int
dstW
,
int
y
,
enum
PixelFormat
target
,
int
hasAlpha
)
{
int
i
;
int
step
=
c
->
dstFormatBpp
/
8
;
int
aidx
=
3
;
switch
(
c
->
dstFormat
)
{
case
PIX_FMT_ARGB
:
dest
++
;
aidx
=
0
;
case
PIX_FMT_RGB24
:
aidx
--
;
case
PIX_FMT_RGBA
:
if
(
CONFIG_SMALL
)
{
int
needAlpha
=
CONFIG_SWSCALE_ALPHA
&&
c
->
alpPixBuf
;
YSCALE_YUV_2_RGBX_FULL_C
(
1
<<
21
,
needAlpha
)
dest
[
aidx
]
=
needAlpha
?
A
:
255
;
dest
[
0
]
=
R
>>
22
;
dest
[
1
]
=
G
>>
22
;
dest
[
2
]
=
B
>>
22
;
dest
+=
step
;
}
}
else
{
if
(
CONFIG_SWSCALE_ALPHA
&&
c
->
alpPixBuf
)
{
YSCALE_YUV_2_RGBX_FULL_C
(
1
<<
21
,
1
)
dest
[
aidx
]
=
A
;
dest
[
0
]
=
R
>>
22
;
dest
[
1
]
=
G
>>
22
;
dest
[
2
]
=
B
>>
22
;
dest
+=
step
;
}
}
else
{
YSCALE_YUV_2_RGBX_FULL_C
(
1
<<
21
,
0
)
dest
[
aidx
]
=
255
;
dest
[
0
]
=
R
>>
22
;
dest
[
1
]
=
G
>>
22
;
dest
[
2
]
=
B
>>
22
;
dest
+=
step
;
}
}
int
step
=
(
target
==
PIX_FMT_RGB24
||
target
==
PIX_FMT_BGR24
)
?
3
:
4
;
for
(
i
=
0
;
i
<
dstW
;
i
++
)
{
int
j
;
int
Y
=
0
;
int
U
=
-
128
<<
19
;
int
V
=
-
128
<<
19
;
int
av_unused
A
;
int
R
,
G
,
B
;
for
(
j
=
0
;
j
<
lumFilterSize
;
j
++
)
{
Y
+=
lumSrc
[
j
][
i
]
*
lumFilter
[
j
];
}
break
;
case
PIX_FMT_ABGR
:
dest
++
;
aidx
=
0
;
case
PIX_FMT_BGR24
:
aidx
--
;
case
PIX_FMT_BGRA
:
if
(
CONFIG_SMALL
)
{
int
needAlpha
=
CONFIG_SWSCALE_ALPHA
&&
c
->
alpPixBuf
;
YSCALE_YUV_2_RGBX_FULL_C
(
1
<<
21
,
needAlpha
)
dest
[
aidx
]
=
needAlpha
?
A
:
255
;
dest
[
0
]
=
B
>>
22
;
dest
[
1
]
=
G
>>
22
;
dest
[
2
]
=
R
>>
22
;
dest
+=
step
;
}
}
else
{
if
(
CONFIG_SWSCALE_ALPHA
&&
c
->
alpPixBuf
)
{
YSCALE_YUV_2_RGBX_FULL_C
(
1
<<
21
,
1
)
dest
[
aidx
]
=
A
;
dest
[
0
]
=
B
>>
22
;
dest
[
1
]
=
G
>>
22
;
dest
[
2
]
=
R
>>
22
;
dest
+=
step
;
}
}
else
{
YSCALE_YUV_2_RGBX_FULL_C
(
1
<<
21
,
0
)
dest
[
aidx
]
=
255
;
dest
[
0
]
=
B
>>
22
;
dest
[
1
]
=
G
>>
22
;
dest
[
2
]
=
R
>>
22
;
dest
+=
step
;
}
for
(
j
=
0
;
j
<
chrFilterSize
;
j
++
)
{
U
+=
chrUSrc
[
j
][
i
]
*
chrFilter
[
j
];
V
+=
chrVSrc
[
j
][
i
]
*
chrFilter
[
j
];
}
Y
>>=
10
;
U
>>=
10
;
V
>>=
10
;
if
(
hasAlpha
)
{
A
=
1
<<
21
;
for
(
j
=
0
;
j
<
lumFilterSize
;
j
++
)
{
A
+=
alpSrc
[
j
][
i
]
*
lumFilter
[
j
];
}
A
>>=
19
;
if
(
A
&
0x100
)
A
=
av_clip_uint8
(
A
);
}
break
;
default
:
assert
(
0
);
Y
-=
c
->
yuv2rgb_y_offset
;
Y
*=
c
->
yuv2rgb_y_coeff
;
Y
+=
1
<<
21
;
R
=
Y
+
V
*
c
->
yuv2rgb_v2r_coeff
;
G
=
Y
+
V
*
c
->
yuv2rgb_v2g_coeff
+
U
*
c
->
yuv2rgb_u2g_coeff
;
B
=
Y
+
U
*
c
->
yuv2rgb_u2b_coeff
;
if
((
R
|
G
|
B
)
&
0xC0000000
)
{
R
=
av_clip_uintp2
(
R
,
30
);
G
=
av_clip_uintp2
(
G
,
30
);
B
=
av_clip_uintp2
(
B
,
30
);
}
switch
(
target
)
{
case
PIX_FMT_ARGB
:
dest
[
0
]
=
hasAlpha
?
A
:
255
;
dest
[
1
]
=
R
>>
22
;
dest
[
2
]
=
G
>>
22
;
dest
[
3
]
=
B
>>
22
;
break
;
case
PIX_FMT_RGB24
:
dest
[
0
]
=
R
>>
22
;
dest
[
1
]
=
G
>>
22
;
dest
[
2
]
=
B
>>
22
;
break
;
case
PIX_FMT_RGBA
:
dest
[
0
]
=
R
>>
22
;
dest
[
1
]
=
G
>>
22
;
dest
[
2
]
=
B
>>
22
;
dest
[
3
]
=
hasAlpha
?
A
:
255
;
break
;
case
PIX_FMT_ABGR
:
dest
[
0
]
=
hasAlpha
?
A
:
255
;
dest
[
1
]
=
B
>>
22
;
dest
[
2
]
=
G
>>
22
;
dest
[
3
]
=
R
>>
22
;
dest
+=
4
;
break
;
case
PIX_FMT_BGR24
:
dest
[
0
]
=
B
>>
22
;
dest
[
1
]
=
G
>>
22
;
dest
[
2
]
=
R
>>
22
;
break
;
case
PIX_FMT_BGRA
:
dest
[
0
]
=
B
>>
22
;
dest
[
1
]
=
G
>>
22
;
dest
[
2
]
=
R
>>
22
;
dest
[
3
]
=
hasAlpha
?
A
:
255
;
break
;
}
dest
+=
step
;
}
}
#if CONFIG_SMALL
YUV2RGBWRAPPERX
(
yuv2
,
rgb_full
,
bgra32_full
,
PIX_FMT_BGRA
,
CONFIG_SWSCALE_ALPHA
&&
c
->
alpPixBuf
);
YUV2RGBWRAPPERX
(
yuv2
,
rgb_full
,
abgr32_full
,
PIX_FMT_ABGR
,
CONFIG_SWSCALE_ALPHA
&&
c
->
alpPixBuf
);
YUV2RGBWRAPPERX
(
yuv2
,
rgb_full
,
rgba32_full
,
PIX_FMT_RGBA
,
CONFIG_SWSCALE_ALPHA
&&
c
->
alpPixBuf
);
YUV2RGBWRAPPERX
(
yuv2
,
rgb_full
,
argb32_full
,
PIX_FMT_ARGB
,
CONFIG_SWSCALE_ALPHA
&&
c
->
alpPixBuf
);
#else
#if CONFIG_SWSCALE_ALPHA
YUV2RGBWRAPPERX
(
yuv2
,
rgb_full
,
bgra32_full
,
PIX_FMT_BGRA
,
1
);
YUV2RGBWRAPPERX
(
yuv2
,
rgb_full
,
abgr32_full
,
PIX_FMT_ABGR
,
1
);
YUV2RGBWRAPPERX
(
yuv2
,
rgb_full
,
rgba32_full
,
PIX_FMT_RGBA
,
1
);
YUV2RGBWRAPPERX
(
yuv2
,
rgb_full
,
argb32_full
,
PIX_FMT_ARGB
,
1
);
#endif
YUV2RGBWRAPPERX
(
yuv2
,
rgb_full
,
bgrx32_full
,
PIX_FMT_BGRA
,
0
);
YUV2RGBWRAPPERX
(
yuv2
,
rgb_full
,
xbgr32_full
,
PIX_FMT_ABGR
,
0
);
YUV2RGBWRAPPERX
(
yuv2
,
rgb_full
,
rgbx32_full
,
PIX_FMT_RGBA
,
0
);
YUV2RGBWRAPPERX
(
yuv2
,
rgb_full
,
xrgb32_full
,
PIX_FMT_ARGB
,
0
);
#endif
YUV2RGBWRAPPERX
(
yuv2
,
rgb_full
,
bgr24_full
,
PIX_FMT_BGR24
,
0
);
YUV2RGBWRAPPERX
(
yuv2
,
rgb_full
,
rgb24_full
,
PIX_FMT_RGB24
,
0
);
static
av_always_inline
void
fillPlane
(
uint8_t
*
plane
,
int
stride
,
int
width
,
int
height
,
int
y
,
uint8_t
val
)
...
...
@@ -1978,7 +1965,70 @@ find_c_packed_planar_out_funcs(SwsContext *c,
*
yuv2yuvX
=
yuv2yuvX_c
;
}
if
(
c
->
flags
&
SWS_FULL_CHR_H_INT
)
{
*
yuv2packedX
=
yuv2rgbX_c_full
;
switch
(
dstFormat
)
{
case
PIX_FMT_RGBA
:
#if CONFIG_SMALL
*
yuv2packedX
=
yuv2rgba32_full_X_c
;
#else
#if CONFIG_SWSCALE_ALPHA
if
(
c
->
alpPixBuf
)
{
*
yuv2packedX
=
yuv2rgba32_full_X_c
;
}
else
#endif
/* CONFIG_SWSCALE_ALPHA */
{
*
yuv2packedX
=
yuv2rgbx32_full_X_c
;
}
#endif
/* !CONFIG_SMALL */
break
;
case
PIX_FMT_ARGB
:
#if CONFIG_SMALL
*
yuv2packedX
=
yuv2argb32_full_X_c
;
#else
#if CONFIG_SWSCALE_ALPHA
if
(
c
->
alpPixBuf
)
{
*
yuv2packedX
=
yuv2argb32_full_X_c
;
}
else
#endif
/* CONFIG_SWSCALE_ALPHA */
{
*
yuv2packedX
=
yuv2xrgb32_full_X_c
;
}
#endif
/* !CONFIG_SMALL */
break
;
case
PIX_FMT_BGRA
:
#if CONFIG_SMALL
*
yuv2packedX
=
yuv2bgra32_full_X_c
;
#else
#if CONFIG_SWSCALE_ALPHA
if
(
c
->
alpPixBuf
)
{
*
yuv2packedX
=
yuv2bgra32_full_X_c
;
}
else
#endif
/* CONFIG_SWSCALE_ALPHA */
{
*
yuv2packedX
=
yuv2bgrx32_full_X_c
;
}
#endif
/* !CONFIG_SMALL */
break
;
case
PIX_FMT_ABGR
:
#if CONFIG_SMALL
*
yuv2packedX
=
yuv2abgr32_full_X_c
;
#else
#if CONFIG_SWSCALE_ALPHA
if
(
c
->
alpPixBuf
)
{
*
yuv2packedX
=
yuv2abgr32_full_X_c
;
}
else
#endif
/* CONFIG_SWSCALE_ALPHA */
{
*
yuv2packedX
=
yuv2xbgr32_full_X_c
;
}
#endif
/* !CONFIG_SMALL */
break
;
case
PIX_FMT_RGB24
:
*
yuv2packedX
=
yuv2rgb24_full_X_c
;
break
;
case
PIX_FMT_BGR24
:
*
yuv2packedX
=
yuv2bgr24_full_X_c
;
break
;
}
}
else
{
switch
(
dstFormat
)
{
case
PIX_FMT_GRAY16BE
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录