Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
aom-rav1e
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiph.Org
aom-rav1e
Commits
374eaf20
Commit
374eaf20
authored
11 years ago
by
Dmitry Kovalev
Browse files
Options
Downloads
Patches
Plain Diff
Flushing the encoder in simple_decoder example.
Change-Id: I39d78facc79a364cdc529b8cc4930d74f766d413
parent
c00d88cd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/simple_encoder.c
+31
-24
31 additions, 24 deletions
examples/simple_encoder.c
with
31 additions
and
24 deletions
examples/simple_encoder.c
+
31
−
24
View file @
374eaf20
...
...
@@ -99,6 +99,33 @@ void usage_exit() {
exit
(
EXIT_FAILURE
);
}
static
void
encode_frame
(
vpx_codec_ctx_t
*
codec
,
vpx_image_t
*
img
,
int
frame_index
,
VpxVideoWriter
*
writer
)
{
vpx_codec_iter_t
iter
=
NULL
;
const
vpx_codec_cx_pkt_t
*
pkt
=
NULL
;
const
vpx_codec_err_t
res
=
vpx_codec_encode
(
codec
,
img
,
frame_index
,
1
,
0
,
VPX_DL_GOOD_QUALITY
);
if
(
res
!=
VPX_CODEC_OK
)
die_codec
(
codec
,
"Failed to encode frame"
);
while
((
pkt
=
vpx_codec_get_cx_data
(
codec
,
&
iter
))
!=
NULL
)
{
if
(
pkt
->
kind
==
VPX_CODEC_CX_FRAME_PKT
)
{
const
int
keyframe
=
(
pkt
->
data
.
frame
.
flags
&
VPX_FRAME_IS_KEY
)
!=
0
;
if
(
!
vpx_video_writer_write_frame
(
writer
,
pkt
->
data
.
frame
.
buf
,
pkt
->
data
.
frame
.
sz
,
pkt
->
data
.
frame
.
pts
))
{
die_codec
(
codec
,
"Failed to write compressed frame"
);
}
printf
(
keyframe
?
"K"
:
"."
);
fflush
(
stdout
);
}
}
}
int
main
(
int
argc
,
char
**
argv
)
{
FILE
*
infile
=
NULL
;
vpx_codec_ctx_t
codec
;
...
...
@@ -166,30 +193,10 @@ int main(int argc, char **argv) {
if
(
vpx_codec_enc_init
(
&
codec
,
encoder
->
interface
(),
&
cfg
,
0
))
die_codec
(
&
codec
,
"Failed to initialize encoder"
);
while
(
vpx_img_read
(
&
raw
,
infile
))
{
vpx_codec_iter_t
iter
=
NULL
;
const
vpx_codec_cx_pkt_t
*
pkt
=
NULL
;
++
frame_count
;
res
=
vpx_codec_encode
(
&
codec
,
&
raw
,
frame_count
,
1
,
0
,
VPX_DL_GOOD_QUALITY
);
if
(
res
!=
VPX_CODEC_OK
)
die_codec
(
&
codec
,
"Failed to encode frame"
);
while
((
pkt
=
vpx_codec_get_cx_data
(
&
codec
,
&
iter
))
!=
NULL
)
{
if
(
pkt
->
kind
==
VPX_CODEC_CX_FRAME_PKT
)
{
const
int
keyframe
=
(
pkt
->
data
.
frame
.
flags
&
VPX_FRAME_IS_KEY
)
!=
0
;
if
(
!
vpx_video_writer_write_frame
(
writer
,
pkt
->
data
.
frame
.
buf
,
pkt
->
data
.
frame
.
sz
,
pkt
->
data
.
frame
.
pts
))
die_codec
(
&
codec
,
"Failed to write compressed frame."
);
printf
(
keyframe
?
"K"
:
"."
);
fflush
(
stdout
);
}
}
}
while
(
vpx_img_read
(
&
raw
,
infile
))
encode_frame
(
&
codec
,
&
raw
,
frame_count
++
,
writer
);
encode_frame
(
&
codec
,
NULL
,
-
1
,
writer
);
// flush the encoder
printf
(
"
\n
"
);
fclose
(
infile
);
printf
(
"Processed %d frames.
\n
"
,
frame_count
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment