summaryrefslogtreecommitdiff
path: root/examples/simple_encoder.c
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2014-02-25 16:34:49 -0800
committerDmitry Kovalev <dkovalev@google.com>2014-02-25 16:34:49 -0800
commit194e6f2983f02e50c0489dc50a8ec203e9433f3a (patch)
treebdcfb6119e1cdefb0b00928a9e3af17ed8a5a88b /examples/simple_encoder.c
parent4632a96d9771b49d6edfe78b68e5dfbafa75fff3 (diff)
downloadlibvpx-194e6f2983f02e50c0489dc50a8ec203e9433f3a.tar.gz
libvpx-194e6f2983f02e50c0489dc50a8ec203e9433f3a.tar.bz2
libvpx-194e6f2983f02e50c0489dc50a8ec203e9433f3a.zip
Merging error-resilient example into simple_encoder.
The only difference between two examples was a setting of g_error_resilient flag in error-resilient example. Moving this functionality into simple_encoder with additional command line option. Change-Id: I0245793320125926e1bf208cc1e87aef39ca478d
Diffstat (limited to 'examples/simple_encoder.c')
-rw-r--r--examples/simple_encoder.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/examples/simple_encoder.c b/examples/simple_encoder.c
index e419e81e1..6ecd4984f 100644
--- a/examples/simple_encoder.c
+++ b/examples/simple_encoder.c
@@ -36,7 +36,7 @@
// ---------------------------------
// Encoders have the notion of "usage profiles." For example, an encoder
// may want to publish default configurations for both a video
-// conferencing appliction and a best quality offline encoder. These
+// conferencing application and a best quality offline encoder. These
// obviously have very different default settings. Consult the
// documentation for your codec to see if it provides any default
// configurations. All codecs provide a default configuration, number 0,
@@ -80,6 +80,13 @@
// an error, a descriptive message is printed and the program exits. With
// few exeptions, vpx_codec functions return an enumerated error status,
// with the value `0` indicating success.
+//
+// Error Resiliency Features
+// -------------------------
+// Error resiliency is controlled by the g_error_resilient member of the
+// configuration structure. Use the `decode_with_drops` example to decode with
+// frames 5-10 dropped. Compare the output for a file encoded with this example
+// versus one encoded with the `simple_encoder` example.
#include <stdio.h>
#include <stdlib.h>
@@ -94,7 +101,10 @@
static const char *exec_name;
void usage_exit() {
- fprintf(stderr, "Usage: %s <codec> <width> <height> <infile> <outfile>\n",
+ fprintf(stderr,
+ "Usage: %s <codec> <width> <height> <infile> <outfile> "
+ "[<error-resilient>]\nSee comments in simple_encoder.c for more "
+ "information.\n",
exec_name);
exit(EXIT_FAILURE);
}
@@ -138,17 +148,23 @@ int main(int argc, char **argv) {
const VpxInterface *encoder = NULL;
const int fps = 30; // TODO(dkovalev) add command line argument
const int bitrate = 200; // kbit/s TODO(dkovalev) add command line argument
- const char *const codec_arg = argv[1];
- const char *const width_arg = argv[2];
- const char *const height_arg = argv[3];
- const char *const infile_arg = argv[4];
- const char *const outfile_arg = argv[5];
+ const char *codec_arg = NULL;
+ const char *width_arg = NULL;
+ const char *height_arg = NULL;
+ const char *infile_arg = NULL;
+ const char *outfile_arg = NULL;
exec_name = argv[0];
- if (argc != 6)
+ if (argc < 6)
die("Invalid number of arguments");
+ codec_arg = argv[1];
+ width_arg = argv[2];
+ height_arg = argv[3];
+ infile_arg = argv[4];
+ outfile_arg = argv[5];
+
encoder = get_vpx_encoder_by_name(codec_arg);
if (!encoder)
die("Unsupported codec.");
@@ -182,6 +198,7 @@ int main(int argc, char **argv) {
cfg.g_timebase.num = info.time_base.numerator;
cfg.g_timebase.den = info.time_base.denominator;
cfg.rc_target_bitrate = bitrate;
+ cfg.g_error_resilient = argc > 6 ? strtol(argv[6], NULL, 0) : 0;
writer = vpx_video_writer_open(outfile_arg, kContainerIVF, &info);
if (!writer)