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
1cccf936
Commit
1cccf936
authored
Nov 17, 2018
by
Martin Vignali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/proresdec : put unpack alpha func in prores ctx
parent
9a22e6fa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
47 deletions
+54
-47
proresdec.h
libavcodec/proresdec.h
+1
-0
proresdec2.c
libavcodec/proresdec2.c
+53
-47
No files found.
libavcodec/proresdec.h
View file @
1cccf936
...
...
@@ -50,6 +50,7 @@ typedef struct {
const
uint8_t
*
scan
;
int
first_field
;
int
alpha_info
;
void
(
*
unpack_alpha
)(
GetBitContext
*
gb
,
uint16_t
*
dst
,
int
num_coeffs
,
const
int
num_bits
);
}
ProresContext
;
#endif
/* AVCODEC_PRORESDEC_H */
libavcodec/proresdec2.c
View file @
1cccf936
...
...
@@ -46,6 +46,51 @@ static void permute(uint8_t *dst, const uint8_t *src, const uint8_t permutation[
dst
[
i
]
=
permutation
[
src
[
i
]];
}
static
void
unpack_alpha_10
(
GetBitContext
*
gb
,
uint16_t
*
dst
,
int
num_coeffs
,
const
int
num_bits
)
{
const
int
mask
=
(
1
<<
num_bits
)
-
1
;
int
i
,
idx
,
val
,
alpha_val
;
idx
=
0
;
alpha_val
=
mask
;
do
{
do
{
if
(
get_bits1
(
gb
))
{
val
=
get_bits
(
gb
,
num_bits
);
}
else
{
int
sign
;
val
=
get_bits
(
gb
,
num_bits
==
16
?
7
:
4
);
sign
=
val
&
1
;
val
=
(
val
+
2
)
>>
1
;
if
(
sign
)
val
=
-
val
;
}
alpha_val
=
(
alpha_val
+
val
)
&
mask
;
if
(
num_bits
==
16
)
{
dst
[
idx
++
]
=
alpha_val
>>
6
;
}
else
{
dst
[
idx
++
]
=
(
alpha_val
<<
2
)
|
(
alpha_val
>>
6
);
}
if
(
idx
>=
num_coeffs
)
break
;
}
while
(
get_bits_left
(
gb
)
>
0
&&
get_bits1
(
gb
));
val
=
get_bits
(
gb
,
4
);
if
(
!
val
)
val
=
get_bits
(
gb
,
11
);
if
(
idx
+
val
>
num_coeffs
)
val
=
num_coeffs
-
idx
;
if
(
num_bits
==
16
)
{
for
(
i
=
0
;
i
<
val
;
i
++
)
dst
[
idx
++
]
=
alpha_val
>>
6
;
}
else
{
for
(
i
=
0
;
i
<
val
;
i
++
)
dst
[
idx
++
]
=
(
alpha_val
<<
2
)
|
(
alpha_val
>>
6
);
}
}
while
(
idx
<
num_coeffs
);
}
static
av_cold
int
decode_init
(
AVCodecContext
*
avctx
)
{
int
ret
=
0
;
...
...
@@ -91,6 +136,12 @@ static av_cold int decode_init(AVCodecContext *avctx)
permute
(
ctx
->
progressive_scan
,
ff_prores_progressive_scan
,
idct_permutation
);
permute
(
ctx
->
interlaced_scan
,
ff_prores_interlaced_scan
,
idct_permutation
);
if
(
avctx
->
bits_per_raw_sample
==
10
){
ctx
->
unpack_alpha
=
unpack_alpha_10
;
}
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
;
}
return
ret
;
}
...
...
@@ -466,51 +517,6 @@ static int decode_slice_chroma(AVCodecContext *avctx, SliceContext *slice,
return
0
;
}
static
void
unpack_alpha
(
GetBitContext
*
gb
,
uint16_t
*
dst
,
int
num_coeffs
,
const
int
num_bits
)
{
const
int
mask
=
(
1
<<
num_bits
)
-
1
;
int
i
,
idx
,
val
,
alpha_val
;
idx
=
0
;
alpha_val
=
mask
;
do
{
do
{
if
(
get_bits1
(
gb
))
{
val
=
get_bits
(
gb
,
num_bits
);
}
else
{
int
sign
;
val
=
get_bits
(
gb
,
num_bits
==
16
?
7
:
4
);
sign
=
val
&
1
;
val
=
(
val
+
2
)
>>
1
;
if
(
sign
)
val
=
-
val
;
}
alpha_val
=
(
alpha_val
+
val
)
&
mask
;
if
(
num_bits
==
16
)
{
dst
[
idx
++
]
=
alpha_val
>>
6
;
}
else
{
dst
[
idx
++
]
=
(
alpha_val
<<
2
)
|
(
alpha_val
>>
6
);
}
if
(
idx
>=
num_coeffs
)
break
;
}
while
(
get_bits_left
(
gb
)
>
0
&&
get_bits1
(
gb
));
val
=
get_bits
(
gb
,
4
);
if
(
!
val
)
val
=
get_bits
(
gb
,
11
);
if
(
idx
+
val
>
num_coeffs
)
val
=
num_coeffs
-
idx
;
if
(
num_bits
==
16
)
{
for
(
i
=
0
;
i
<
val
;
i
++
)
dst
[
idx
++
]
=
alpha_val
>>
6
;
}
else
{
for
(
i
=
0
;
i
<
val
;
i
++
)
dst
[
idx
++
]
=
(
alpha_val
<<
2
)
|
(
alpha_val
>>
6
);
}
}
while
(
idx
<
num_coeffs
);
}
/**
* Decode alpha slice plane.
*/
...
...
@@ -530,9 +536,9 @@ static void decode_slice_alpha(ProresContext *ctx,
init_get_bits
(
&
gb
,
buf
,
buf_size
<<
3
);
if
(
ctx
->
alpha_info
==
2
)
{
unpack_alpha
(
&
gb
,
blocks
,
blocks_per_slice
*
4
*
64
,
16
);
ctx
->
unpack_alpha
(
&
gb
,
blocks
,
blocks_per_slice
*
4
*
64
,
16
);
}
else
{
unpack_alpha
(
&
gb
,
blocks
,
blocks_per_slice
*
4
*
64
,
8
);
ctx
->
unpack_alpha
(
&
gb
,
blocks
,
blocks_per_slice
*
4
*
64
,
8
);
}
block
=
blocks
;
...
...
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