Index: source/libvpx/vpxdec.c |
=================================================================== |
--- source/libvpx/vpxdec.c (revision 284462) |
+++ source/libvpx/vpxdec.c (working copy) |
@@ -55,6 +55,8 @@ |
"Output raw I420 frames"); |
static const arg_def_t flipuvarg = ARG_DEF(NULL, "flipuv", 0, |
"Flip the chroma planes in the output"); |
+static const arg_def_t rawvideo = ARG_DEF(NULL, "rawvideo", 0, |
+ "Output raw YUV frames"); |
static const arg_def_t noblitarg = ARG_DEF(NULL, "noblit", 0, |
"Don't process the decoded frames"); |
static const arg_def_t progressarg = ARG_DEF(NULL, "progress", 0, |
@@ -87,7 +89,7 @@ |
"Compute the MD5 sum of the decoded frame"); |
static const arg_def_t *all_args[] = { |
- &codecarg, &use_yv12, &use_i420, &flipuvarg, &noblitarg, |
+ &codecarg, &use_yv12, &use_i420, &flipuvarg, &rawvideo, &noblitarg, |
&progressarg, &limitarg, &skiparg, &postprocarg, &summaryarg, &outputfile, |
&threadsarg, &verbosearg, &scalearg, &fb_arg, |
&md5arg, &error_concealment, &continuearg, |
@@ -166,7 +168,7 @@ |
for (i = 0; i < get_vpx_decoder_count(); ++i) { |
const VpxInterface *const decoder = get_vpx_decoder_by_index(i); |
fprintf(stderr, " %-6s - %s\n", |
- decoder->name, vpx_codec_iface_name(decoder->interface())); |
+ decoder->name, vpx_codec_iface_name(decoder->codec_interface())); |
} |
exit(EXIT_FAILURE); |
@@ -286,7 +288,7 @@ |
if (mem_get_le32(buf) < 256 * 1024 * 1024) { |
for (i = 0; i < get_vpx_decoder_count(); ++i) { |
const VpxInterface *const decoder = get_vpx_decoder_by_index(i); |
- if (!vpx_codec_peek_stream_info(decoder->interface(), |
+ if (!vpx_codec_peek_stream_info(decoder->codec_interface(), |
buf + 4, 32 - 4, &si)) { |
is_raw = 1; |
input->fourcc = decoder->fourcc; |
@@ -507,6 +509,8 @@ |
int single_file; |
int use_y4m = 1; |
+ int opt_yv12 = 0; |
+ int opt_i420 = 0; |
vpx_codec_dec_cfg_t cfg = {0}; |
#if CONFIG_VP8_DECODER |
vp8_postproc_cfg_t vp8_pp_cfg = {0}; |
@@ -557,9 +561,13 @@ |
else if (arg_match(&arg, &use_yv12, argi)) { |
use_y4m = 0; |
flipuv = 1; |
+ opt_yv12 = 1; |
} else if (arg_match(&arg, &use_i420, argi)) { |
use_y4m = 0; |
flipuv = 0; |
+ opt_i420 = 1; |
+ } else if (arg_match(&arg, &rawvideo, argi)) { |
+ use_y4m = 0; |
} else if (arg_match(&arg, &flipuvarg, argi)) |
flipuv = 1; |
else if (arg_match(&arg, &noblitarg, argi)) |
@@ -728,7 +736,8 @@ |
dec_flags = (postproc ? VPX_CODEC_USE_POSTPROC : 0) | |
(ec_enabled ? VPX_CODEC_USE_ERROR_CONCEALMENT : 0); |
- if (vpx_codec_dec_init(&decoder, interface->interface(), &cfg, dec_flags)) { |
+ if (vpx_codec_dec_init(&decoder, interface->codec_interface(), |
+ &cfg, dec_flags)) { |
fprintf(stderr, "Failed to initialize decoder: %s\n", |
vpx_codec_error(&decoder)); |
return EXIT_FAILURE; |
@@ -875,6 +884,7 @@ |
} |
scaled_img = vpx_img_alloc(NULL, VPX_IMG_FMT_I420, display_width, |
display_height, 16); |
+ scaled_img->bit_depth = img->bit_depth; |
} |
if (img->d_w != scaled_img->d_w || img->d_h != scaled_img->d_h) { |
@@ -901,7 +911,7 @@ |
vpx_input_ctx.width, |
vpx_input_ctx.height, |
&vpx_input_ctx.framerate, |
- img->fmt, 8); |
+ img->fmt, img->bit_depth); |
if (do_md5) { |
MD5Update(&md5_ctx, (md5byte *)buf, (unsigned int)len); |
} else { |
@@ -916,6 +926,25 @@ |
} else { |
fputs(buf, outfile); |
} |
+ } else { |
+ if (frame_out == 1) { |
+ // Check if --yv12 or --i420 options are consistent with the |
+ // bit-stream decoded |
+ if (opt_i420) { |
+ if (img->fmt != VPX_IMG_FMT_I420 && |
+ img->fmt != VPX_IMG_FMT_I42016) { |
+ fprintf(stderr, "Cannot produce i420 output for bit-stream.\n"); |
+ goto fail; |
+ } |
+ } |
+ if (opt_yv12) { |
+ if ((img->fmt != VPX_IMG_FMT_I420 && |
+ img->fmt != VPX_IMG_FMT_YV12) || img->bit_depth != 8) { |
+ fprintf(stderr, "Cannot produce yv12 output for bit-stream.\n"); |
+ goto fail; |
+ } |
+ } |
+ } |
} |
if (do_md5) { |