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
1be9a28f
Commit
1be9a28f
authored
Dec 19, 2018
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/rangecoder: factorize termination version code
Signed-off-by:
Michael Niedermayer
<
michael@niedermayer.cc
>
parent
41c1643d
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
12 deletions
+10
-12
ffv1enc.c
libavcodec/ffv1enc.c
+3
-7
rangecoder.c
libavcodec/rangecoder.c
+3
-1
rangecoder.h
libavcodec/rangecoder.h
+1
-1
snowenc.c
libavcodec/snowenc.c
+1
-1
sonic.c
libavcodec/sonic.c
+1
-1
rangecoder.c
libavcodec/tests/rangecoder.c
+1
-1
No files found.
libavcodec/ffv1enc.c
View file @
1be9a28f
...
@@ -449,7 +449,7 @@ static int write_extradata(FFV1Context *f)
...
@@ -449,7 +449,7 @@ static int write_extradata(FFV1Context *f)
put_symbol
(
c
,
state
,
f
->
intra
=
(
f
->
avctx
->
gop_size
<
2
),
0
);
put_symbol
(
c
,
state
,
f
->
intra
=
(
f
->
avctx
->
gop_size
<
2
),
0
);
}
}
f
->
avctx
->
extradata_size
=
ff_rac_terminate
(
c
);
f
->
avctx
->
extradata_size
=
ff_rac_terminate
(
c
,
0
);
v
=
av_crc
(
av_crc_get_table
(
AV_CRC_32_IEEE
),
0
,
f
->
avctx
->
extradata
,
f
->
avctx
->
extradata_size
);
v
=
av_crc
(
av_crc_get_table
(
AV_CRC_32_IEEE
),
0
,
f
->
avctx
->
extradata
,
f
->
avctx
->
extradata_size
);
AV_WL32
(
f
->
avctx
->
extradata
+
f
->
avctx
->
extradata_size
,
v
);
AV_WL32
(
f
->
avctx
->
extradata
+
f
->
avctx
->
extradata_size
,
v
);
f
->
avctx
->
extradata_size
+=
4
;
f
->
avctx
->
extradata_size
+=
4
;
...
@@ -1065,9 +1065,7 @@ retry:
...
@@ -1065,9 +1065,7 @@ retry:
encode_slice_header
(
f
,
fs
);
encode_slice_header
(
f
,
fs
);
}
}
if
(
fs
->
ac
==
AC_GOLOMB_RICE
)
{
if
(
fs
->
ac
==
AC_GOLOMB_RICE
)
{
if
(
f
->
version
>
2
)
fs
->
ac_byte_count
=
f
->
version
>
2
||
(
!
x
&&
!
y
)
?
ff_rac_terminate
(
&
fs
->
c
,
f
->
version
>
2
)
:
0
;
put_rac
(
&
fs
->
c
,
(
uint8_t
[])
{
129
},
0
);
fs
->
ac_byte_count
=
f
->
version
>
2
||
(
!
x
&&
!
y
)
?
ff_rac_terminate
(
&
fs
->
c
)
:
0
;
init_put_bits
(
&
fs
->
pb
,
init_put_bits
(
&
fs
->
pb
,
fs
->
c
.
bytestream_start
+
fs
->
ac_byte_count
,
fs
->
c
.
bytestream_start
+
fs
->
ac_byte_count
,
fs
->
c
.
bytestream_end
-
fs
->
c
.
bytestream_start
-
fs
->
ac_byte_count
);
fs
->
c
.
bytestream_end
-
fs
->
c
.
bytestream_start
-
fs
->
ac_byte_count
);
...
@@ -1232,9 +1230,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
...
@@ -1232,9 +1230,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
int
bytes
;
int
bytes
;
if
(
fs
->
ac
!=
AC_GOLOMB_RICE
)
{
if
(
fs
->
ac
!=
AC_GOLOMB_RICE
)
{
uint8_t
state
=
129
;
bytes
=
ff_rac_terminate
(
&
fs
->
c
,
1
);
put_rac
(
&
fs
->
c
,
&
state
,
0
);
bytes
=
ff_rac_terminate
(
&
fs
->
c
);
}
else
{
}
else
{
flush_put_bits
(
&
fs
->
pb
);
// FIXME: nicer padding
flush_put_bits
(
&
fs
->
pb
);
// FIXME: nicer padding
bytes
=
fs
->
ac_byte_count
+
(
put_bits_count
(
&
fs
->
pb
)
+
7
)
/
8
;
bytes
=
fs
->
ac_byte_count
+
(
put_bits_count
(
&
fs
->
pb
)
+
7
)
/
8
;
...
...
libavcodec/rangecoder.c
View file @
1be9a28f
...
@@ -106,8 +106,10 @@ void ff_build_rac_states(RangeCoder *c, int factor, int max_p)
...
@@ -106,8 +106,10 @@ void ff_build_rac_states(RangeCoder *c, int factor, int max_p)
}
}
/* Return the number of bytes written. */
/* Return the number of bytes written. */
int
ff_rac_terminate
(
RangeCoder
*
c
)
int
ff_rac_terminate
(
RangeCoder
*
c
,
int
version
)
{
{
if
(
version
==
1
)
put_rac
(
c
,
(
uint8_t
[])
{
129
},
0
);
c
->
range
=
0xFF
;
c
->
range
=
0xFF
;
c
->
low
+=
0xFF
;
c
->
low
+=
0xFF
;
renorm_encoder
(
c
);
renorm_encoder
(
c
);
...
...
libavcodec/rangecoder.h
View file @
1be9a28f
...
@@ -48,7 +48,7 @@ typedef struct RangeCoder {
...
@@ -48,7 +48,7 @@ typedef struct RangeCoder {
void
ff_init_range_encoder
(
RangeCoder
*
c
,
uint8_t
*
buf
,
int
buf_size
);
void
ff_init_range_encoder
(
RangeCoder
*
c
,
uint8_t
*
buf
,
int
buf_size
);
void
ff_init_range_decoder
(
RangeCoder
*
c
,
const
uint8_t
*
buf
,
int
buf_size
);
void
ff_init_range_decoder
(
RangeCoder
*
c
,
const
uint8_t
*
buf
,
int
buf_size
);
int
ff_rac_terminate
(
RangeCoder
*
c
);
int
ff_rac_terminate
(
RangeCoder
*
c
,
int
version
);
void
ff_build_rac_states
(
RangeCoder
*
c
,
int
factor
,
int
max_p
);
void
ff_build_rac_states
(
RangeCoder
*
c
,
int
factor
,
int
max_p
);
static
inline
void
renorm_encoder
(
RangeCoder
*
c
)
static
inline
void
renorm_encoder
(
RangeCoder
*
c
)
...
...
libavcodec/snowenc.c
View file @
1be9a28f
...
@@ -1899,7 +1899,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
...
@@ -1899,7 +1899,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
#endif
pkt
->
size
=
ff_rac_terminate
(
c
);
pkt
->
size
=
ff_rac_terminate
(
c
,
0
);
if
(
s
->
current_picture
->
key_frame
)
if
(
s
->
current_picture
->
key_frame
)
pkt
->
flags
|=
AV_PKT_FLAG_KEY
;
pkt
->
flags
|=
AV_PKT_FLAG_KEY
;
*
got_packet
=
1
;
*
got_packet
=
1
;
...
...
libavcodec/sonic.c
View file @
1be9a28f
...
@@ -842,7 +842,7 @@ static int sonic_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
...
@@ -842,7 +842,7 @@ static int sonic_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
// av_log(avctx, AV_LOG_DEBUG, "used bytes: %d\n", (put_bits_count(&pb)+7)/8);
// av_log(avctx, AV_LOG_DEBUG, "used bytes: %d\n", (put_bits_count(&pb)+7)/8);
avpkt
->
size
=
ff_rac_terminate
(
&
c
);
avpkt
->
size
=
ff_rac_terminate
(
&
c
,
0
);
*
got_packet_ptr
=
1
;
*
got_packet_ptr
=
1
;
return
0
;
return
0
;
...
...
libavcodec/tests/rangecoder.c
View file @
1be9a28f
...
@@ -48,7 +48,7 @@ int main(void)
...
@@ -48,7 +48,7 @@ int main(void)
for
(
i
=
0
;
i
<
SIZE
;
i
++
)
for
(
i
=
0
;
i
<
SIZE
;
i
++
)
put_rac
(
&
c
,
state
,
r
[
i
]
&
1
);
put_rac
(
&
c
,
state
,
r
[
i
]
&
1
);
ff_rac_terminate
(
&
c
);
ff_rac_terminate
(
&
c
,
0
);
ff_init_range_decoder
(
&
c
,
b
,
SIZE
);
ff_init_range_decoder
(
&
c
,
b
,
SIZE
);
...
...
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