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
fddc92d4
Commit
fddc92d4
authored
Nov 17, 2018
by
Martin Vignali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/proresdec : add unpack alpha 12 func
parent
859604fe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
6 deletions
+41
-6
proresdec2.c
libavcodec/proresdec2.c
+41
-6
No files found.
libavcodec/proresdec2.c
View file @
fddc92d4
...
...
@@ -46,6 +46,11 @@ static void permute(uint8_t *dst, const uint8_t *src, const uint8_t permutation[
dst
[
i
]
=
permutation
[
src
[
i
]];
}
#define ALPHA_SHIFT_16_TO_10(alpha_val) (alpha_val >> 6)
#define ALPHA_SHIFT_8_TO_10(alpha_val) ((alpha_val << 2) | (alpha_val >> 6))
#define ALPHA_SHIFT_16_TO_12(alpha_val) (alpha_val >> 4)
#define ALPHA_SHIFT_8_TO_12(alpha_val) ((alpha_val << 4) | (alpha_val >> 4))
static
void
inline
unpack_alpha
(
GetBitContext
*
gb
,
uint16_t
*
dst
,
int
num_coeffs
,
const
int
num_bits
,
const
int
decode_precision
)
{
const
int
mask
=
(
1
<<
num_bits
)
-
1
;
...
...
@@ -67,9 +72,17 @@ static void inline unpack_alpha(GetBitContext *gb, uint16_t *dst, int num_coeffs
}
alpha_val
=
(
alpha_val
+
val
)
&
mask
;
if
(
num_bits
==
16
)
{
dst
[
idx
++
]
=
alpha_val
>>
6
;
if
(
decode_precision
==
10
)
{
dst
[
idx
++
]
=
ALPHA_SHIFT_16_TO_10
(
alpha_val
);
}
else
{
/* 12b */
dst
[
idx
++
]
=
ALPHA_SHIFT_16_TO_12
(
alpha_val
);
}
}
else
{
dst
[
idx
++
]
=
(
alpha_val
<<
2
)
|
(
alpha_val
>>
6
);
if
(
decode_precision
==
10
)
{
dst
[
idx
++
]
=
ALPHA_SHIFT_8_TO_10
(
alpha_val
);
}
else
{
/* 12b */
dst
[
idx
++
]
=
ALPHA_SHIFT_8_TO_12
(
alpha_val
);
}
}
if
(
idx
>=
num_coeffs
)
break
;
...
...
@@ -80,11 +93,21 @@ static void inline unpack_alpha(GetBitContext *gb, uint16_t *dst, int num_coeffs
if
(
idx
+
val
>
num_coeffs
)
val
=
num_coeffs
-
idx
;
if
(
num_bits
==
16
)
{
for
(
i
=
0
;
i
<
val
;
i
++
)
dst
[
idx
++
]
=
alpha_val
>>
6
;
for
(
i
=
0
;
i
<
val
;
i
++
)
{
if
(
decode_precision
==
10
)
{
dst
[
idx
++
]
=
ALPHA_SHIFT_16_TO_10
(
alpha_val
);
}
else
{
/* 12b */
dst
[
idx
++
]
=
ALPHA_SHIFT_16_TO_12
(
alpha_val
);
}
}
}
else
{
for
(
i
=
0
;
i
<
val
;
i
++
)
dst
[
idx
++
]
=
(
alpha_val
<<
2
)
|
(
alpha_val
>>
6
);
for
(
i
=
0
;
i
<
val
;
i
++
)
{
if
(
decode_precision
==
10
)
{
dst
[
idx
++
]
=
ALPHA_SHIFT_8_TO_10
(
alpha_val
);
}
else
{
/* 12b */
dst
[
idx
++
]
=
ALPHA_SHIFT_8_TO_12
(
alpha_val
);
}
}
}
}
while
(
idx
<
num_coeffs
);
}
...
...
@@ -99,6 +122,16 @@ static void unpack_alpha_10(GetBitContext *gb, uint16_t *dst, int num_coeffs,
}
}
static
void
unpack_alpha_12
(
GetBitContext
*
gb
,
uint16_t
*
dst
,
int
num_coeffs
,
const
int
num_bits
)
{
if
(
num_bits
==
16
)
{
unpack_alpha
(
gb
,
dst
,
num_coeffs
,
16
,
12
);
}
else
{
/* 8 bits alpha */
unpack_alpha
(
gb
,
dst
,
num_coeffs
,
8
,
12
);
}
}
static
av_cold
int
decode_init
(
AVCodecContext
*
avctx
)
{
int
ret
=
0
;
...
...
@@ -146,6 +179,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
if
(
avctx
->
bits_per_raw_sample
==
10
){
ctx
->
unpack_alpha
=
unpack_alpha_10
;
}
else
if
(
avctx
->
bits_per_raw_sample
==
12
){
ctx
->
unpack_alpha
=
unpack_alpha_12
;
}
else
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Fail to set unpack_alpha for bits per raw sample %d
\n
"
,
avctx
->
bits_per_raw_sample
);
return
AVERROR_BUG
;
...
...
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