Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: source/libvpx/examples/set_maps.c

Issue 484923003: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/configure ('k') | source/libvpx/test/convolve_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/examples/set_maps.c
===================================================================
--- source/libvpx/examples/set_maps.c (revision 291087)
+++ source/libvpx/examples/set_maps.c (working copy)
@@ -125,10 +125,11 @@
die_codec(codec, "Failed to set active map");
}
-static void encode_frame(vpx_codec_ctx_t *codec,
- vpx_image_t *img,
- int frame_index,
- VpxVideoWriter *writer) {
+static int encode_frame(vpx_codec_ctx_t *codec,
+ vpx_image_t *img,
+ int frame_index,
+ VpxVideoWriter *writer) {
+ int got_pkts = 0;
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,
@@ -137,6 +138,8 @@
die_codec(codec, "Failed to encode frame");
while ((pkt = vpx_codec_get_cx_data(codec, &iter)) != NULL) {
+ got_pkts = 1;
+
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,
@@ -150,6 +153,8 @@
fflush(stdout);
}
}
+
+ return got_pkts;
}
int main(int argc, char **argv) {
@@ -217,6 +222,7 @@
if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
die_codec(&codec, "Failed to initialize encoder");
+ // Encode frames.
while (vpx_img_read(&raw, infile)) {
++frame_count;
@@ -230,7 +236,10 @@
encode_frame(&codec, &raw, frame_count, writer);
}
- encode_frame(&codec, NULL, -1, writer);
+
+ // Flush encoder.
+ while (encode_frame(&codec, NULL, -1, writer)) {}
+
printf("\n");
fclose(infile);
printf("Processed %d frames.\n", frame_count);
« no previous file with comments | « source/libvpx/configure ('k') | source/libvpx/test/convolve_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698