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
f5894178
Commit
f5894178
authored
Nov 04, 2018
by
Mark Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cbs_av1: Support redundant frame headers
parent
6bdb7712
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
12 deletions
+91
-12
cbs_av1.c
libavcodec/cbs_av1.c
+12
-4
cbs_av1.h
libavcodec/cbs_av1.h
+4
-1
cbs_av1_syntax_template.c
libavcodec/cbs_av1_syntax_template.c
+75
-7
No files found.
libavcodec/cbs_av1.c
View file @
f5894178
...
...
@@ -996,7 +996,10 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
case
AV1_OBU_REDUNDANT_FRAME_HEADER
:
{
err
=
cbs_av1_read_frame_header_obu
(
ctx
,
&
gbc
,
&
obu
->
obu
.
frame_header
);
&
obu
->
obu
.
frame_header
,
obu
->
header
.
obu_type
==
AV1_OBU_REDUNDANT_FRAME_HEADER
,
unit
->
data_ref
);
if
(
err
<
0
)
return
err
;
}
...
...
@@ -1016,7 +1019,8 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
break
;
case
AV1_OBU_FRAME
:
{
err
=
cbs_av1_read_frame_obu
(
ctx
,
&
gbc
,
&
obu
->
obu
.
frame
);
err
=
cbs_av1_read_frame_obu
(
ctx
,
&
gbc
,
&
obu
->
obu
.
frame
,
unit
->
data_ref
);
if
(
err
<
0
)
return
err
;
...
...
@@ -1124,7 +1128,10 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
case
AV1_OBU_REDUNDANT_FRAME_HEADER
:
{
err
=
cbs_av1_write_frame_header_obu
(
ctx
,
pbc
,
&
obu
->
obu
.
frame_header
);
&
obu
->
obu
.
frame_header
,
obu
->
header
.
obu_type
==
AV1_OBU_REDUNDANT_FRAME_HEADER
,
NULL
);
if
(
err
<
0
)
return
err
;
}
...
...
@@ -1141,7 +1148,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
break
;
case
AV1_OBU_FRAME
:
{
err
=
cbs_av1_write_frame_obu
(
ctx
,
pbc
,
&
obu
->
obu
.
frame
);
err
=
cbs_av1_write_frame_obu
(
ctx
,
pbc
,
&
obu
->
obu
.
frame
,
NULL
);
if
(
err
<
0
)
return
err
;
...
...
@@ -1302,6 +1309,7 @@ static void cbs_av1_close(CodedBitstreamContext *ctx)
CodedBitstreamAV1Context
*
priv
=
ctx
->
priv_data
;
av_buffer_unref
(
&
priv
->
sequence_header_ref
);
av_buffer_unref
(
&
priv
->
frame_header_ref
);
av_freep
(
&
priv
->
write_buffer
);
}
...
...
libavcodec/cbs_av1.h
View file @
f5894178
...
...
@@ -399,7 +399,10 @@ typedef struct CodedBitstreamAV1Context {
AV1RawSequenceHeader
*
sequence_header
;
AVBufferRef
*
sequence_header_ref
;
int
seen_frame_header
;
int
seen_frame_header
;
AVBufferRef
*
frame_header_ref
;
uint8_t
*
frame_header
;
size_t
frame_header_size
;
int
temporal_id
;
int
spatial_id
;
...
...
libavcodec/cbs_av1_syntax_template.c
View file @
f5894178
...
...
@@ -1463,24 +1463,90 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
}
static
int
FUNC
(
frame_header_obu
)(
CodedBitstreamContext
*
ctx
,
RWContext
*
rw
,
AV1RawFrameHeader
*
current
)
AV1RawFrameHeader
*
current
,
int
redundant
,
AVBufferRef
*
rw_buffer_ref
)
{
CodedBitstreamAV1Context
*
priv
=
ctx
->
priv_data
;
int
err
;
HEADER
(
"Frame Header"
);
int
start_pos
,
fh_bits
,
fh_bytes
,
err
;
uint8_t
*
fh_start
;
if
(
priv
->
seen_frame_header
)
{
// Nothing to do.
if
(
!
redundant
)
{
av_log
(
ctx
->
log_ctx
,
AV_LOG_ERROR
,
"Invalid repeated "
"frame header OBU.
\n
"
);
return
AVERROR_INVALIDDATA
;
}
else
{
GetBitContext
fh
;
size_t
i
,
b
;
uint32_t
val
;
HEADER
(
"Redundant Frame Header"
);
av_assert0
(
priv
->
frame_header_ref
&&
priv
->
frame_header
);
init_get_bits
(
&
fh
,
priv
->
frame_header
,
priv
->
frame_header_size
);
for
(
i
=
0
;
i
<
priv
->
frame_header_size
;
i
+=
8
)
{
b
=
FFMIN
(
priv
->
frame_header_size
-
i
,
8
);
val
=
get_bits
(
&
fh
,
b
);
xf
(
b
,
frame_header_copy
[
i
],
val
,
val
,
val
,
1
,
i
/
8
);
}
}
}
else
{
if
(
redundant
)
HEADER
(
"Redundant Frame Header (used as Frame Header)"
);
else
HEADER
(
"Frame Header"
);
priv
->
seen_frame_header
=
1
;
#ifdef READ
start_pos
=
get_bits_count
(
rw
);
#else
start_pos
=
put_bits_count
(
rw
);
#endif
CHECK
(
FUNC
(
uncompressed_header
)(
ctx
,
rw
,
current
));
if
(
current
->
show_existing_frame
)
{
priv
->
seen_frame_header
=
0
;
}
else
{
priv
->
seen_frame_header
=
1
;
av_buffer_unref
(
&
priv
->
frame_header_ref
);
#ifdef READ
fh_bits
=
get_bits_count
(
rw
)
-
start_pos
;
fh_start
=
(
uint8_t
*
)
rw
->
buffer
+
start_pos
/
8
;
#else
// Need to flush the bitwriter so that we can copy its output,
// but use a copy so we don't affect the caller's structure.
{
PutBitContext
tmp
=
*
rw
;
flush_put_bits
(
&
tmp
);
}
fh_bits
=
put_bits_count
(
rw
)
-
start_pos
;
fh_start
=
rw
->
buf
+
start_pos
/
8
;
#endif
fh_bytes
=
(
fh_bits
+
7
)
/
8
;
priv
->
frame_header_size
=
fh_bits
;
if
(
rw_buffer_ref
)
{
priv
->
frame_header_ref
=
av_buffer_ref
(
rw_buffer_ref
);
if
(
!
priv
->
frame_header_ref
)
return
AVERROR
(
ENOMEM
);
priv
->
frame_header
=
fh_start
;
}
else
{
priv
->
frame_header_ref
=
av_buffer_alloc
(
fh_bytes
+
AV_INPUT_BUFFER_PADDING_SIZE
);
if
(
!
priv
->
frame_header_ref
)
return
AVERROR
(
ENOMEM
);
priv
->
frame_header
=
priv
->
frame_header_ref
->
data
;
memcpy
(
priv
->
frame_header
,
fh_start
,
fh_bytes
);
}
}
}
...
...
@@ -1524,11 +1590,13 @@ static int FUNC(tile_group_obu)(CodedBitstreamContext *ctx, RWContext *rw,
}
static
int
FUNC
(
frame_obu
)(
CodedBitstreamContext
*
ctx
,
RWContext
*
rw
,
AV1RawFrame
*
current
)
AV1RawFrame
*
current
,
AVBufferRef
*
rw_buffer_ref
)
{
int
err
;
CHECK
(
FUNC
(
frame_header_obu
)(
ctx
,
rw
,
&
current
->
header
));
CHECK
(
FUNC
(
frame_header_obu
)(
ctx
,
rw
,
&
current
->
header
,
0
,
rw_buffer_ref
));
CHECK
(
FUNC
(
byte_alignment
)(
ctx
,
rw
));
...
...
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