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
7b41cbac
Commit
7b41cbac
authored
Jan 13, 2014
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/huffman: extend ff_huff_gen_len_table() to allow >8bit
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
af68bd1c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
9 deletions
+22
-9
huffman.c
libavcodec/huffman.c
+15
-5
huffman.h
libavcodec/huffman.h
+1
-1
huffyuvenc.c
libavcodec/huffyuvenc.c
+3
-2
utvideoenc.c
libavcodec/utvideoenc.c
+3
-1
No files found.
libavcodec/huffman.c
View file @
7b41cbac
...
...
@@ -52,13 +52,18 @@ static void heap_sift(HeapElem *h, int root, int size)
}
}
void
ff_huff_gen_len_table
(
uint8_t
*
dst
,
const
uint64_t
*
stats
)
int
ff_huff_gen_len_table
(
uint8_t
*
dst
,
const
uint64_t
*
stats
,
int
size
)
{
HeapElem
h
[
256
]
;
int
up
[
2
*
256
]
;
int
len
[
2
*
256
]
;
HeapElem
*
h
=
av_malloc
(
sizeof
(
*
h
)
*
size
)
;
int
*
up
=
av_malloc
(
sizeof
(
*
up
)
*
2
*
size
)
;
uint8_t
*
len
=
av_malloc
(
sizeof
(
*
len
)
*
2
*
size
)
;
int
offset
,
i
,
next
;
int
size
=
256
;
int
ret
=
0
;
if
(
!
h
||
!
up
||
!
len
)
{
ret
=
AVERROR
(
ENOMEM
);
goto
end
;
}
for
(
offset
=
1
;
;
offset
<<=
1
)
{
for
(
i
=
0
;
i
<
size
;
i
++
)
{
...
...
@@ -89,6 +94,11 @@ void ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats)
}
if
(
i
==
size
)
break
;
}
end:
av_free
(
h
);
av_free
(
up
);
av_free
(
len
);
return
ret
;
}
static
void
get_tree_codes
(
uint32_t
*
bits
,
int16_t
*
lens
,
uint8_t
*
xlat
,
...
...
libavcodec/huffman.h
View file @
7b41cbac
...
...
@@ -43,6 +43,6 @@ typedef int (*HuffCmp)(const void *va, const void *vb);
int
ff_huff_build_tree
(
AVCodecContext
*
avctx
,
VLC
*
vlc
,
int
nb_codes
,
int
nb_bits
,
Node
*
nodes
,
HuffCmp
cmp
,
int
flags
);
void
ff_huff_gen_len_table
(
uint8_t
*
dst
,
const
uint64_t
*
stats
);
int
ff_huff_gen_len_table
(
uint8_t
*
dst
,
const
uint64_t
*
stats
,
int
n
);
#endif
/* AVCODEC_HUFFMAN_H */
libavcodec/huffyuvenc.c
View file @
7b41cbac
...
...
@@ -144,7 +144,7 @@ static int store_table(HYuvContext *s, const uint8_t *len, uint8_t *buf)
static
int
store_huffman_tables
(
HYuvContext
*
s
,
uint8_t
*
buf
)
{
int
i
;
int
i
,
ret
;
int
size
=
0
;
int
count
=
3
;
...
...
@@ -152,7 +152,8 @@ static int store_huffman_tables(HYuvContext *s, uint8_t *buf)
count
=
1
+
s
->
alpha
+
2
*
s
->
chroma
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
ff_huff_gen_len_table
(
s
->
len
[
i
],
s
->
stats
[
i
]);
if
((
ret
=
ff_huff_gen_len_table
(
s
->
len
[
i
],
s
->
stats
[
i
],
256
))
<
0
)
return
ret
;
if
(
ff_huffyuv_generate_bits_table
(
s
->
bits
[
i
],
s
->
len
[
i
])
<
0
)
{
return
-
1
;
...
...
libavcodec/utvideoenc.c
View file @
7b41cbac
...
...
@@ -363,6 +363,7 @@ static int encode_plane(AVCodecContext *avctx, uint8_t *src,
uint32_t
offset
=
0
,
slice_len
=
0
;
int
i
,
sstart
,
send
=
0
;
int
symbol
;
int
ret
;
/* Do prediction / make planes */
switch
(
c
->
frame_pred
)
{
...
...
@@ -429,7 +430,8 @@ static int encode_plane(AVCodecContext *avctx, uint8_t *src,
}
/* Calculate huffman lengths */
ff_huff_gen_len_table
(
lengths
,
counts
);
if
((
ret
=
ff_huff_gen_len_table
(
lengths
,
counts
,
256
))
<
0
)
return
ret
;
/*
* Write the plane's header into the output packet:
...
...
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