Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
f43fd68f
Commit
f43fd68f
authored
May 02, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/drawutils: add support for full range
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
177133a0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
8 deletions
+26
-8
drawutils.c
libavfilter/drawutils.c
+8
-3
drawutils.h
libavfilter/drawutils.h
+1
-0
colorspace.h
libavutil/colorspace.h
+12
-0
filter-pixfmts-pad
tests/ref/fate/filter-pixfmts-pad
+5
-5
No files found.
libavfilter/drawutils.c
View file @
f43fd68f
...
@@ -181,6 +181,7 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
...
@@ -181,6 +181,7 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
const
AVComponentDescriptor
*
c
;
const
AVComponentDescriptor
*
c
;
unsigned
i
,
nb_planes
=
0
;
unsigned
i
,
nb_planes
=
0
;
int
pixelstep
[
MAX_PLANES
]
=
{
0
};
int
pixelstep
[
MAX_PLANES
]
=
{
0
};
int
full_range
=
0
;
if
(
!
desc
||
!
desc
->
name
)
if
(
!
desc
||
!
desc
->
name
)
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
...
@@ -188,6 +189,9 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
...
@@ -188,6 +189,9 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
return
AVERROR
(
ENOSYS
);
return
AVERROR
(
ENOSYS
);
if
(
format
==
AV_PIX_FMT_P010LE
||
format
==
AV_PIX_FMT_P010BE
||
format
==
AV_PIX_FMT_P016LE
||
format
==
AV_PIX_FMT_P016BE
)
if
(
format
==
AV_PIX_FMT_P010LE
||
format
==
AV_PIX_FMT_P010BE
||
format
==
AV_PIX_FMT_P016LE
||
format
==
AV_PIX_FMT_P016BE
)
return
AVERROR
(
ENOSYS
);
return
AVERROR
(
ENOSYS
);
if
(
format
==
AV_PIX_FMT_YUVJ420P
||
format
==
AV_PIX_FMT_YUVJ422P
||
format
==
AV_PIX_FMT_YUVJ444P
||
format
==
AV_PIX_FMT_YUVJ411P
||
format
==
AV_PIX_FMT_YUVJ440P
)
full_range
=
1
;
for
(
i
=
0
;
i
<
desc
->
nb_components
;
i
++
)
{
for
(
i
=
0
;
i
<
desc
->
nb_components
;
i
++
)
{
c
=
&
desc
->
comp
[
i
];
c
=
&
desc
->
comp
[
i
];
/* for now, only 8-16 bits formats */
/* for now, only 8-16 bits formats */
...
@@ -214,6 +218,7 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
...
@@ -214,6 +218,7 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
draw
->
format
=
format
;
draw
->
format
=
format
;
draw
->
nb_planes
=
nb_planes
;
draw
->
nb_planes
=
nb_planes
;
draw
->
flags
=
flags
;
draw
->
flags
=
flags
;
draw
->
full_range
=
full_range
;
memcpy
(
draw
->
pixelstep
,
pixelstep
,
sizeof
(
draw
->
pixelstep
));
memcpy
(
draw
->
pixelstep
,
pixelstep
,
sizeof
(
draw
->
pixelstep
));
draw
->
hsub
[
1
]
=
draw
->
hsub
[
2
]
=
draw
->
hsub_max
=
desc
->
log2_chroma_w
;
draw
->
hsub
[
1
]
=
draw
->
hsub
[
2
]
=
draw
->
hsub_max
=
desc
->
log2_chroma_w
;
draw
->
vsub
[
1
]
=
draw
->
vsub
[
2
]
=
draw
->
vsub_max
=
desc
->
log2_chroma_h
;
draw
->
vsub
[
1
]
=
draw
->
vsub
[
2
]
=
draw
->
vsub_max
=
desc
->
log2_chroma_h
;
...
@@ -249,9 +254,9 @@ void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4
...
@@ -249,9 +254,9 @@ void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4
}
else
if
(
draw
->
nb_planes
>=
2
)
{
}
else
if
(
draw
->
nb_planes
>=
2
)
{
/* assume YUV */
/* assume YUV */
const
AVPixFmtDescriptor
*
desc
=
draw
->
desc
;
const
AVPixFmtDescriptor
*
desc
=
draw
->
desc
;
color
->
comp
[
desc
->
comp
[
0
].
plane
].
u8
[
desc
->
comp
[
0
].
offset
]
=
RGB_TO_Y_CCIR
(
rgba
[
0
],
rgba
[
1
],
rgba
[
2
]);
color
->
comp
[
desc
->
comp
[
0
].
plane
].
u8
[
desc
->
comp
[
0
].
offset
]
=
draw
->
full_range
?
RGB_TO_Y_JPEG
(
rgba
[
0
],
rgba
[
1
],
rgba
[
2
])
:
RGB_TO_Y_CCIR
(
rgba
[
0
],
rgba
[
1
],
rgba
[
2
]);
color
->
comp
[
desc
->
comp
[
1
].
plane
].
u8
[
desc
->
comp
[
1
].
offset
]
=
RGB_TO_U_CCIR
(
rgba
[
0
],
rgba
[
1
],
rgba
[
2
],
0
);
color
->
comp
[
desc
->
comp
[
1
].
plane
].
u8
[
desc
->
comp
[
1
].
offset
]
=
draw
->
full_range
?
RGB_TO_U_JPEG
(
rgba
[
0
],
rgba
[
1
],
rgba
[
2
])
:
RGB_TO_U_CCIR
(
rgba
[
0
],
rgba
[
1
],
rgba
[
2
],
0
);
color
->
comp
[
desc
->
comp
[
2
].
plane
].
u8
[
desc
->
comp
[
2
].
offset
]
=
RGB_TO_V_CCIR
(
rgba
[
0
],
rgba
[
1
],
rgba
[
2
],
0
);
color
->
comp
[
desc
->
comp
[
2
].
plane
].
u8
[
desc
->
comp
[
2
].
offset
]
=
draw
->
full_range
?
RGB_TO_V_JPEG
(
rgba
[
0
],
rgba
[
1
],
rgba
[
2
])
:
RGB_TO_V_CCIR
(
rgba
[
0
],
rgba
[
1
],
rgba
[
2
],
0
);
color
->
comp
[
3
].
u8
[
0
]
=
rgba
[
3
];
color
->
comp
[
3
].
u8
[
0
]
=
rgba
[
3
];
#define EXPAND(compn) \
#define EXPAND(compn) \
if (desc->comp[compn].depth > 8) \
if (desc->comp[compn].depth > 8) \
...
...
libavfilter/drawutils.h
View file @
f43fd68f
...
@@ -55,6 +55,7 @@ typedef struct FFDrawContext {
...
@@ -55,6 +55,7 @@ typedef struct FFDrawContext {
uint8_t
vsub
[
MAX_PLANES
];
/*< vertical subsampling */
uint8_t
vsub
[
MAX_PLANES
];
/*< vertical subsampling */
uint8_t
hsub_max
;
uint8_t
hsub_max
;
uint8_t
vsub_max
;
uint8_t
vsub_max
;
int
full_range
;
unsigned
flags
;
unsigned
flags
;
}
FFDrawContext
;
}
FFDrawContext
;
...
...
libavutil/colorspace.h
View file @
f43fd68f
...
@@ -107,4 +107,16 @@ static inline int C_JPEG_TO_CCIR(int y) {
...
@@ -107,4 +107,16 @@ static inline int C_JPEG_TO_CCIR(int y) {
(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \
(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \
FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
#define RGB_TO_Y_JPEG(r, g, b) \
(FFMIN((FIX(0.29900) * (r) + FIX(0.58700) * (g) + \
FIX(0.11400) * (b) + (ONE_HALF)) >> SCALEBITS, 255))
#define RGB_TO_U_JPEG(r1, g1, b1)\
(((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + \
FIX(0.50000) * b1 + (ONE_HALF) - 1) >> (SCALEBITS)) + 128)
#define RGB_TO_V_JPEG(r1, g1, b1)\
(((FIX(0.50000) * r1 - FIX(0.41869) * g1 - \
FIX(0.08131) * b1 + (ONE_HALF) - 1) >> (SCALEBITS)) + 128)
#endif
/* AVUTIL_COLORSPACE_H */
#endif
/* AVUTIL_COLORSPACE_H */
tests/ref/fate/filter-pixfmts-pad
View file @
f43fd68f
...
@@ -62,8 +62,8 @@ yuva444p fb60941a57596b277417a3c7c00aa194
...
@@ -62,8 +62,8 @@ yuva444p fb60941a57596b277417a3c7c00aa194
yuva444p10le 251ea4ead8300d752eb355a08cbb0352
yuva444p10le 251ea4ead8300d752eb355a08cbb0352
yuva444p16le 5b65287e1862d2d9f1ad2cfdcde94661
yuva444p16le 5b65287e1862d2d9f1ad2cfdcde94661
yuva444p9le e6946c10b94c271e7ea24b3bcff314e1
yuva444p9le e6946c10b94c271e7ea24b3bcff314e1
yuvj411p
ca967e68759a4956729dd366adc7e7fa
yuvj411p
87dbac57b211ab4823c1abbd702f1516
yuvj420p
c00611cd5f1558047d579d8a7d30e381
yuvj420p
1abef62bce65131ca4913eb2006fd860
yuvj422p
b3acdf07147a7598836065836ad8420b
yuvj422p
198c57b519e2be14b150889bd7f94898
yuvj440p
3446ba4b1d7fdf536c926cee643c2b35
yuvj440p
e6533260d197ad15e39319117c57473e
yuvj444p
3b0f1a185af048b9e0b202d003fc7e62
yuvj444p
26a44748960513783ea676eff409d89a
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment