ref: 8aa33ed6b1ae93b81652fa2e060e0cff5bd0aaa1
parent: 326b73e41e1fcbc0ddf90971cab203a09ca812ce
author: Charles 'Buck' Krasic <[email protected]>
date: Fri Jan 3 11:06:35 EST 2014
Write correct resolution to the IVF file header (b/11270652) also: o remove dead code, create_dummy_frame o Fix a bug in command line handling that caused a segfault if wrong number of arguments were given. Change-Id: I78f026aee4e363967b750e6cde0982659c558a1f
--- a/vp9_spatial_scalable_encoder.c
+++ b/vp9_spatial_scalable_encoder.c
@@ -79,7 +79,9 @@
struct VpxInputContext input_ctx;
} AppInput;
-void usage_exit(const char *exec_name) {
+static const char *exec_name;
+
+void usage_exit() {
fprintf(stderr, "Usage: %s <options> input_filename output_filename\n",
exec_name);
fprintf(stderr, "Options:\n");
@@ -95,12 +97,6 @@
exit(EXIT_FAILURE);
}
-static int create_dummy_frame(vpx_image_t *img) {
- const size_t buf_size = img->w * img->h * 3 / 2;
- memset(img->planes[0], 129, buf_size);
- return 1;
-}
-
static void parse_command_line(int argc, const char **argv_,
AppInput *app_input, SvcContext *svc_ctx,
vpx_codec_enc_cfg_t *enc_cfg) {
@@ -170,7 +166,7 @@
die("Error: Unrecognized option %s\n", *argi);
if (argv[0] == NULL || argv[1] == 0) {
- usage_exit(argv_[0]);
+ usage_exit();
}
app_input->input_ctx.filename = argv[0];
app_input->output_filename = argv[1];
@@ -210,6 +206,7 @@
memset(&svc_ctx, 0, sizeof(svc_ctx));
svc_ctx.log_print = 1;
+ exec_name = argv[0];
parse_command_line(argc, argv, &app_input, &svc_ctx, &enc_cfg);
// Allocate image buffer
@@ -260,8 +257,16 @@
fclose(app_input.input_ctx.file);
if (vpx_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec");
- // rewrite the output file headers with the actual frame count
+ // rewrite the output file headers with the actual frame count, and
+ // resolution of the highest layer
if (!fseek(outfile, 0, SEEK_SET)) {
+ // get resolution of highest layer
+ if (VPX_CODEC_OK != vpx_svc_get_layer_resolution(&svc_ctx,
+ svc_ctx.spatial_layers - 1,
+ &enc_cfg.g_w,
+ &enc_cfg.g_h)) {
+ die("Failed to get output resolution");
+ }
ivf_write_file_header(outfile, &enc_cfg, VP9_FOURCC, frame_cnt);
}
fclose(outfile);
--- a/vpx/exports_enc
+++ b/vpx/exports_enc
@@ -20,3 +20,4 @@
text vpx_svc_set_options
text vpx_svc_set_quantizers
text vpx_svc_set_scale_factors
+text vpx_svc_get_layer_resolution