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
9d098ea3
Commit
9d098ea3
authored
Jan 08, 2014
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/huffyuvenc: Factorize store_huffman_tables() out
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
9e7b477c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
24 deletions
+29
-24
huffyuvenc.c
libavcodec/huffyuvenc.c
+29
-24
No files found.
libavcodec/huffyuvenc.c
View file @
9d098ea3
...
...
@@ -142,12 +142,33 @@ static int store_table(HYuvContext *s, const uint8_t *len, uint8_t *buf)
return
index
;
}
static
int
store_huffman_tables
(
HYuvContext
*
s
,
uint8_t
*
buf
)
{
int
i
;
int
size
=
0
;
int
count
=
3
;
if
(
s
->
version
>
2
)
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
(
ff_huffyuv_generate_bits_table
(
s
->
bits
[
i
],
s
->
len
[
i
])
<
0
)
{
return
-
1
;
}
size
+=
store_table
(
s
,
s
->
len
[
i
],
buf
+
size
);
}
return
size
;
}
static
av_cold
int
encode_init
(
AVCodecContext
*
avctx
)
{
HYuvContext
*
s
=
avctx
->
priv_data
;
int
i
,
j
;
int
ret
;
const
AVPixFmtDescriptor
*
desc
=
av_pix_fmt_desc_get
(
avctx
->
pix_fmt
);
int
extradata_tables
;
ff_huffyuv_common_init
(
avctx
);
...
...
@@ -257,7 +278,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
return
AVERROR
(
EINVAL
);
}
extradata_tables
=
1
+
2
*
s
->
chroma
+
s
->
alpha
;
((
uint8_t
*
)
avctx
->
extradata
)[
0
]
=
s
->
predictor
|
(
s
->
decorrelate
<<
6
);
((
uint8_t
*
)
avctx
->
extradata
)[
2
]
=
s
->
interlaced
?
0x10
:
0x20
;
if
(
s
->
context
)
...
...
@@ -265,7 +285,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
if
(
s
->
version
<
3
)
{
((
uint8_t
*
)
avctx
->
extradata
)[
1
]
=
s
->
bitstream_bpp
;
((
uint8_t
*
)
avctx
->
extradata
)[
3
]
=
0
;
extradata_tables
=
3
;
}
else
{
((
uint8_t
*
)
avctx
->
extradata
)[
1
]
=
((
s
->
bps
-
1
)
<<
4
)
|
s
->
chroma_h_shift
|
(
s
->
chroma_v_shift
<<
2
);
if
(
s
->
chroma
)
...
...
@@ -304,16 +323,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
}
}
for
(
i
=
0
;
i
<
extradata_tables
;
i
++
)
{
ff_huff_gen_len_table
(
s
->
len
[
i
],
s
->
stats
[
i
]);
if
(
ff_huffyuv_generate_bits_table
(
s
->
bits
[
i
],
s
->
len
[
i
])
<
0
)
{
return
-
1
;
}
s
->
avctx
->
extradata_size
+=
store_table
(
s
,
s
->
len
[
i
],
&
((
uint8_t
*
)
s
->
avctx
->
extradata
)[
s
->
avctx
->
extradata_size
]);
}
ret
=
store_huffman_tables
(
s
,
s
->
avctx
->
extradata
+
s
->
avctx
->
extradata_size
);
if
(
ret
<
0
)
return
ret
;
s
->
avctx
->
extradata_size
+=
ret
;
if
(
s
->
context
)
{
for
(
i
=
0
;
i
<
4
;
i
++
)
{
...
...
@@ -554,17 +567,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return
ret
;
if
(
s
->
context
)
{
int
count
=
3
;
if
(
s
->
version
>
2
)
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
(
ff_huffyuv_generate_bits_table
(
s
->
bits
[
i
],
s
->
len
[
i
])
<
0
)
return
-
1
;
size
+=
store_table
(
s
,
s
->
len
[
i
],
&
pkt
->
data
[
size
]);
}
size
=
store_huffman_tables
(
s
,
pkt
->
data
);
if
(
size
<
0
)
return
size
;
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
j
=
0
;
j
<
256
;
j
++
)
...
...
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