Index: source/libvpx/vpxenc.c |
=================================================================== |
--- source/libvpx/vpxenc.c (revision 278778) |
+++ source/libvpx/vpxenc.c (working copy) |
@@ -755,7 +755,7 @@ |
input->height = input->y4m.pic_h; |
input->framerate.numerator = input->y4m.fps_n; |
input->framerate.denominator = input->y4m.fps_d; |
- input->use_i420 = 0; |
+ input->fmt = input->y4m.vpx_fmt; |
} else |
fatal("Unsupported Y4M stream."); |
} else if (input->detect.buf_read == 4 && fourcc_is_ivf(input->detect.buf)) { |
@@ -1059,7 +1059,24 @@ |
} |
} |
+static const char* file_type_to_string(enum VideoFileType t) { |
+ switch (t) { |
+ case FILE_TYPE_RAW: return "RAW"; |
+ case FILE_TYPE_Y4M: return "Y4M"; |
+ default: return "Other"; |
+ } |
+} |
+static const char* image_format_to_string(vpx_img_fmt_t f) { |
+ switch (f) { |
+ case VPX_IMG_FMT_I420: return "I420"; |
+ case VPX_IMG_FMT_I422: return "I422"; |
+ case VPX_IMG_FMT_I444: return "I444"; |
+ case VPX_IMG_FMT_YV12: return "YV12"; |
+ default: return "Other"; |
+ } |
+} |
+ |
static void show_stream_config(struct stream_state *stream, |
struct VpxEncoderConfig *global, |
struct VpxInputContext *input) { |
@@ -1070,8 +1087,10 @@ |
if (stream->index == 0) { |
fprintf(stderr, "Codec: %s\n", |
vpx_codec_iface_name(global->codec->interface())); |
- fprintf(stderr, "Source file: %s Format: %s\n", input->filename, |
- input->use_i420 ? "I420" : "YV12"); |
+ fprintf(stderr, "Source file: %s File Type: %s Format: %s\n", |
+ input->filename, |
+ file_type_to_string(input->file_type), |
+ image_format_to_string(input->fmt)); |
} |
if (stream->next || stream->index) |
fprintf(stderr, "\nStream Index: %d\n", stream->index); |
@@ -1245,6 +1264,11 @@ |
/* Scale if necessary */ |
if (img && (img->d_w != cfg->g_w || img->d_h != cfg->g_h)) { |
+ if (img->fmt != VPX_IMG_FMT_I420 && img->fmt != VPX_IMG_FMT_YV12) { |
+ fprintf(stderr, "%s can only scale 4:2:0 8bpp inputs\n", exec_name); |
+ exit(EXIT_FAILURE); |
+ } |
+#if CONFIG_LIBYUV |
if (!stream->img) |
stream->img = vpx_img_alloc(NULL, VPX_IMG_FMT_I420, |
cfg->g_w, cfg->g_h, 16); |
@@ -1260,8 +1284,15 @@ |
stream->img->stride[VPX_PLANE_V], |
stream->img->d_w, stream->img->d_h, |
kFilterBox); |
- |
img = stream->img; |
+#else |
+ stream->encoder.err = 1; |
+ ctx_exit_on_error(&stream->encoder, |
+ "Stream %d: Failed to encode frame.\n" |
+ "Scaling disabled in this configuration. \n" |
+ "To enable, configure with --enable-libyuv\n", |
+ stream->index); |
+#endif |
} |
vpx_usec_timer_start(&timer); |
@@ -1501,7 +1532,6 @@ |
/* Setup default input stream settings */ |
input.framerate.numerator = 30; |
input.framerate.denominator = 1; |
- input.use_i420 = 1; |
input.only_i420 = 1; |
/* First parse the global configuration values, because we want to apply |
@@ -1511,6 +1541,7 @@ |
argv = argv_dup(argc - 1, argv_ + 1); |
parse_global_config(&global, argv); |
+ input.fmt = global.use_i420 ? VPX_IMG_FMT_I420 : VPX_IMG_FMT_YV12; |
{ |
/* Now parse each stream's parameters. Using a local scope here |
@@ -1611,10 +1642,7 @@ |
frames.*/ |
memset(&raw, 0, sizeof(raw)); |
else |
- vpx_img_alloc(&raw, |
- input.use_i420 ? VPX_IMG_FMT_I420 |
- : VPX_IMG_FMT_YV12, |
- input.width, input.height, 32); |
+ vpx_img_alloc(&raw, input.fmt, input.width, input.height, 32); |
FOREACH_STREAM(stream->rate_hist = |
init_rate_histogram(&stream->config.cfg, |