Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
BC
public
external
libvpx
Commits
374eaf20
Commit
374eaf20
authored
11 years ago
by
Dmitry Kovalev
Browse files
Options
Download
Patches
Plain Diff
Flushing the encoder in simple_decoder example.
Change-Id: I39d78facc79a364cdc529b8cc4930d74f766d413
parent
c00d88cd
v1.14.0-linphone
1.4.X
feature/update_to_v1.9.0-linphone
feature/uwp_nuget
frame_parallel
highbitdepth
indianrunnerduck
javanwhistlingduck
khakicampbell
linphone
linphone-android
linphone-old
longtailedduck
m49-2623
m52-2743
m54-2840
m56-2924
m66-3359
m68-3440
mandarinduck
nextgen
nextgenv2
playground
sandbox/Jingning/experimental
sandbox/Jingning/transcode
sandbox/Jingning/vpx
sandbox/aconverse@google.com/ansbench
sandbox/hkuang/frame_parallel
sandbox/hkuang@google.com/decode
sandbox/jimbankoski@google.com/proposed-aom
sandbox/jingning@google.com/decoder_test_suite
sandbox/jingning@google.com/experimental
sandbox/jzern@google.com/test
sandbox/wangch@google.com/vp9
sandbox/yaowu@google.com/mergeaom
v1.12.0-linphone
v1.6.1_linphone
v1.7.0-linphone
v1.9.0-linphone
v1.9.0
v1.9.0-rc1
v1.8.2
v1.8.1
v1.8.0
v1.7.0
v1.6.1
v1.6.0
v1.5.0
v1.4.0
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/simple_encoder.c
+31
-24
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() {
...
@@ -99,6 +99,33 @@ void usage_exit() {
exit
(
EXIT_FAILURE
);
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
)
{
int
main
(
int
argc
,
char
**
argv
)
{
FILE
*
infile
=
NULL
;
FILE
*
infile
=
NULL
;
vpx_codec_ctx_t
codec
;
vpx_codec_ctx_t
codec
;
...
@@ -166,30 +193,10 @@ int main(int argc, char **argv) {
...
@@ -166,30 +193,10 @@ int main(int argc, char **argv) {
if
(
vpx_codec_enc_init
(
&
codec
,
encoder
->
interface
(),
&
cfg
,
0
))
if
(
vpx_codec_enc_init
(
&
codec
,
encoder
->
interface
(),
&
cfg
,
0
))
die_codec
(
&
codec
,
"Failed to initialize encoder"
);
die_codec
(
&
codec
,
"Failed to initialize encoder"
);
while
(
vpx_img_read
(
&
raw
,
infile
))
{
while
(
vpx_img_read
(
&
raw
,
infile
))
vpx_codec_iter_t
iter
=
NULL
;
encode_frame
(
&
codec
,
&
raw
,
frame_count
++
,
writer
);
const
vpx_codec_cx_pkt_t
*
pkt
=
NULL
;
encode_frame
(
&
codec
,
NULL
,
-
1
,
writer
);
// flush the encoder
++
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
);
}
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
fclose
(
infile
);
fclose
(
infile
);
printf
(
"Processed %d frames.
\n
"
,
frame_count
);
printf
(
"Processed %d frames.
\n
"
,
frame_count
);
...
...
This diff is collapsed.
Click to expand it.
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets