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
4d93c63e
Commit
4d93c63e
authored
Jan 25, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/magicyuvenc: write max huffman length and extradata too
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
1f75756c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
5 deletions
+37
-5
magicyuvenc.c
libavcodec/magicyuvenc.c
+37
-5
No files found.
libavcodec/magicyuvenc.c
View file @
4d93c63e
...
...
@@ -57,7 +57,6 @@ typedef struct MagicYUVContext {
int
planes
;
uint8_t
format
;
AVFrame
*
p
;
int
max
;
int
slice_height
;
int
nb_slices
;
int
correlate
;
...
...
@@ -148,6 +147,7 @@ static void median_predict(MagicYUVContext *s,
static
av_cold
int
magy_encode_init
(
AVCodecContext
*
avctx
)
{
MagicYUVContext
*
s
=
avctx
->
priv_data
;
PutByteContext
pb
;
int
i
;
switch
(
avctx
->
pix_fmt
)
{
...
...
@@ -214,6 +214,34 @@ static av_cold int magy_encode_init(AVCodecContext *avctx)
case
MEDIAN
:
s
->
predict
=
median_predict
;
break
;
}
avctx
->
extradata_size
=
32
;
avctx
->
extradata
=
av_mallocz
(
avctx
->
extradata_size
+
AV_INPUT_BUFFER_PADDING_SIZE
);
if
(
!
avctx
->
extradata
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Could not allocate extradata.
\n
"
);
return
AVERROR
(
ENOMEM
);
}
bytestream2_init_writer
(
&
pb
,
avctx
->
extradata
,
avctx
->
extradata_size
);
bytestream2_put_le32
(
&
pb
,
MKTAG
(
'M'
,
'A'
,
'G'
,
'Y'
));
bytestream2_put_le32
(
&
pb
,
32
);
bytestream2_put_byte
(
&
pb
,
7
);
bytestream2_put_byte
(
&
pb
,
s
->
format
);
bytestream2_put_byte
(
&
pb
,
12
);
bytestream2_put_byte
(
&
pb
,
0
);
bytestream2_put_byte
(
&
pb
,
0
);
bytestream2_put_byte
(
&
pb
,
0
);
bytestream2_put_byte
(
&
pb
,
32
);
bytestream2_put_byte
(
&
pb
,
0
);
bytestream2_put_le32
(
&
pb
,
avctx
->
width
);
bytestream2_put_le32
(
&
pb
,
avctx
->
height
);
bytestream2_put_le32
(
&
pb
,
avctx
->
width
);
bytestream2_put_le32
(
&
pb
,
avctx
->
height
);
return
0
;
}
...
...
@@ -347,7 +375,7 @@ static int encode_table(AVCodecContext *avctx, uint8_t *dst,
counts
[
i
].
value
=
255
-
i
;
}
magy_huffman_compute_bits
(
counts
,
he
,
256
,
1
6
);
magy_huffman_compute_bits
(
counts
,
he
,
256
,
1
2
);
calculate_codes
(
he
);
...
...
@@ -407,12 +435,16 @@ static int magy_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
bytestream2_init_writer
(
&
pb
,
pkt
->
data
,
pkt
->
size
);
bytestream2_put_le32
(
&
pb
,
MKTAG
(
'M'
,
'A'
,
'G'
,
'Y'
));
bytestream2_put_le32
(
&
pb
,
32
);
bytestream2_put_byte
(
&
pb
,
7
);
bytestream2_put_le32
(
&
pb
,
32
);
// header size
bytestream2_put_byte
(
&
pb
,
7
);
// version
bytestream2_put_byte
(
&
pb
,
s
->
format
);
bytestream2_put_byte
(
&
pb
,
12
);
// max huffman length
bytestream2_put_byte
(
&
pb
,
0
);
bytestream2_put_byte
(
&
pb
,
0
);
bytestream2_put_byte
(
&
pb
,
0
);
bytestream2_put_byte
(
&
pb
,
32
);
// coder type
bytestream2_put_byte
(
&
pb
,
0
);
bytestream2_put_le32
(
&
pb
,
0
);
bytestream2_put_le32
(
&
pb
,
avctx
->
width
);
bytestream2_put_le32
(
&
pb
,
avctx
->
height
);
...
...
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