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

Side by Side Diff: source/libvpx/vpxdec.c

Issue 554673004: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vpx_scale/yv12config.h ('k') | source/libvpx/vpxenc.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 static const arg_def_t scalearg = ARG_DEF("S", "scale", 0, 83 static const arg_def_t scalearg = ARG_DEF("S", "scale", 0,
84 "Scale output frames uniformly"); 84 "Scale output frames uniformly");
85 static const arg_def_t continuearg = 85 static const arg_def_t continuearg =
86 ARG_DEF("k", "keep-going", 0, "(debug) Continue decoding after error"); 86 ARG_DEF("k", "keep-going", 0, "(debug) Continue decoding after error");
87 87
88 static const arg_def_t fb_arg = 88 static const arg_def_t fb_arg =
89 ARG_DEF(NULL, "frame-buffers", 1, "Number of frame buffers to use"); 89 ARG_DEF(NULL, "frame-buffers", 1, "Number of frame buffers to use");
90 90
91 static const arg_def_t md5arg = ARG_DEF(NULL, "md5", 0, 91 static const arg_def_t md5arg = ARG_DEF(NULL, "md5", 0,
92 "Compute the MD5 sum of the decoded fram e"); 92 "Compute the MD5 sum of the decoded fram e");
93 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
94 static const arg_def_t outbitdeptharg = ARG_DEF(
95 NULL, "output-bit-depth", 1,
96 "Output bit-depth for decoded frames");
97 #endif
93 98
94 static const arg_def_t *all_args[] = { 99 static const arg_def_t *all_args[] = {
95 &codecarg, &use_yv12, &use_i420, &flipuvarg, &rawvideo, &noblitarg, 100 &codecarg, &use_yv12, &use_i420, &flipuvarg, &rawvideo, &noblitarg,
96 &progressarg, &limitarg, &skiparg, &postprocarg, &summaryarg, &outputfile, 101 &progressarg, &limitarg, &skiparg, &postprocarg, &summaryarg, &outputfile,
97 &threadsarg, &verbosearg, &scalearg, &fb_arg, 102 &threadsarg, &verbosearg, &scalearg, &fb_arg,
98 &md5arg, &error_concealment, &continuearg, 103 &md5arg, &error_concealment, &continuearg,
104 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
105 &outbitdeptharg,
106 #endif
99 NULL 107 NULL
100 }; 108 };
101 109
102 #if CONFIG_VP8_DECODER 110 #if CONFIG_VP8_DECODER
103 static const arg_def_t addnoise_level = ARG_DEF(NULL, "noise-level", 1, 111 static const arg_def_t addnoise_level = ARG_DEF(NULL, "noise-level", 1,
104 "Enable VP8 postproc add noise") ; 112 "Enable VP8 postproc add noise") ;
105 static const arg_def_t deblock = ARG_DEF(NULL, "deblock", 0, 113 static const arg_def_t deblock = ARG_DEF(NULL, "deblock", 0,
106 "Enable VP8 deblocking"); 114 "Enable VP8 deblocking");
107 static const arg_def_t demacroblock_level = ARG_DEF(NULL, "demacroblock-level", 1, 115 static const arg_def_t demacroblock_level = ARG_DEF(NULL, "demacroblock-level", 1,
108 "Enable VP8 demacroblocking, w/ level"); 116 "Enable VP8 demacroblocking, w/ level");
(...skipping 13 matching lines...) Expand all
122 static const arg_def_t *vp8_pp_args[] = { 130 static const arg_def_t *vp8_pp_args[] = {
123 &addnoise_level, &deblock, &demacroblock_level, &pp_debug_info, 131 &addnoise_level, &deblock, &demacroblock_level, &pp_debug_info,
124 &pp_disp_ref_frame, &pp_disp_mb_modes, &pp_disp_b_modes, &pp_disp_mvs, &mfqe, 132 &pp_disp_ref_frame, &pp_disp_mb_modes, &pp_disp_b_modes, &pp_disp_mvs, &mfqe,
125 NULL 133 NULL
126 }; 134 };
127 #endif 135 #endif
128 136
129 #if CONFIG_LIBYUV 137 #if CONFIG_LIBYUV
130 static INLINE int vpx_image_scale(vpx_image_t *src, vpx_image_t *dst, 138 static INLINE int vpx_image_scale(vpx_image_t *src, vpx_image_t *dst,
131 FilterModeEnum mode) { 139 FilterModeEnum mode) {
140 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
141 if (src->fmt == VPX_IMG_FMT_I42016) {
142 assert(dst->fmt == VPX_IMG_FMT_I42016);
143 return I420Scale_16((uint16_t*)src->planes[VPX_PLANE_Y],
144 src->stride[VPX_PLANE_Y]/2,
145 (uint16_t*)src->planes[VPX_PLANE_U],
146 src->stride[VPX_PLANE_U]/2,
147 (uint16_t*)src->planes[VPX_PLANE_V],
148 src->stride[VPX_PLANE_V]/2,
149 src->d_w, src->d_h,
150 (uint16_t*)dst->planes[VPX_PLANE_Y],
151 dst->stride[VPX_PLANE_Y]/2,
152 (uint16_t*)dst->planes[VPX_PLANE_U],
153 dst->stride[VPX_PLANE_U]/2,
154 (uint16_t*)dst->planes[VPX_PLANE_V],
155 dst->stride[VPX_PLANE_V]/2,
156 dst->d_w, dst->d_h,
157 mode);
158 }
159 #endif
132 assert(src->fmt == VPX_IMG_FMT_I420); 160 assert(src->fmt == VPX_IMG_FMT_I420);
133 assert(dst->fmt == VPX_IMG_FMT_I420); 161 assert(dst->fmt == VPX_IMG_FMT_I420);
134 return I420Scale(src->planes[VPX_PLANE_Y], src->stride[VPX_PLANE_Y], 162 return I420Scale(src->planes[VPX_PLANE_Y], src->stride[VPX_PLANE_Y],
135 src->planes[VPX_PLANE_U], src->stride[VPX_PLANE_U], 163 src->planes[VPX_PLANE_U], src->stride[VPX_PLANE_U],
136 src->planes[VPX_PLANE_V], src->stride[VPX_PLANE_V], 164 src->planes[VPX_PLANE_V], src->stride[VPX_PLANE_V],
137 src->d_w, src->d_h, 165 src->d_w, src->d_h,
138 dst->planes[VPX_PLANE_Y], dst->stride[VPX_PLANE_Y], 166 dst->planes[VPX_PLANE_Y], dst->stride[VPX_PLANE_Y],
139 dst->planes[VPX_PLANE_U], dst->stride[VPX_PLANE_U], 167 dst->planes[VPX_PLANE_U], dst->stride[VPX_PLANE_U],
140 dst->planes[VPX_PLANE_V], dst->stride[VPX_PLANE_V], 168 dst->planes[VPX_PLANE_V], dst->stride[VPX_PLANE_V],
141 dst->d_w, dst->d_h, 169 dst->d_w, dst->d_h,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 for (y = 0; y < h; ++y) { 286 for (y = 0; y < h; ++y) {
259 MD5Update(md5, buf, w); 287 MD5Update(md5, buf, w);
260 buf += stride; 288 buf += stride;
261 } 289 }
262 } 290 }
263 } 291 }
264 292
265 static void write_image_file(const vpx_image_t *img, const int planes[3], 293 static void write_image_file(const vpx_image_t *img, const int planes[3],
266 FILE *file) { 294 FILE *file) {
267 int i, y; 295 int i, y;
296 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
297 const int bytes_per_sample = ((img->fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? 2 : 1);
298 #else
299 const int bytes_per_sample = 1;
300 #endif
268 301
269 for (i = 0; i < 3; ++i) { 302 for (i = 0; i < 3; ++i) {
270 const int plane = planes[i]; 303 const int plane = planes[i];
271 const unsigned char *buf = img->planes[plane]; 304 const unsigned char *buf = img->planes[plane];
272 const int stride = img->stride[plane]; 305 const int stride = img->stride[plane];
273 const int w = vpx_img_plane_width(img, plane); 306 const int w = vpx_img_plane_width(img, plane);
274 const int h = vpx_img_plane_height(img, plane); 307 const int h = vpx_img_plane_height(img, plane);
275 308
276 for (y = 0; y < h; ++y) { 309 for (y = 0; y < h; ++y) {
277 fwrite(buf, 1, w, file); 310 fwrite(buf, bytes_per_sample, w, file);
278 buf += stride; 311 buf += stride;
279 } 312 }
280 } 313 }
281 } 314 }
282 315
283 int file_is_raw(struct VpxInputContext *input) { 316 int file_is_raw(struct VpxInputContext *input) {
284 uint8_t buf[32]; 317 uint8_t buf[32];
285 int is_raw = 0; 318 int is_raw = 0;
286 vpx_codec_stream_info_t si; 319 vpx_codec_stream_info_t si;
287 320
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 set_binary_mode(stdout); 520 set_binary_mode(stdout);
488 return stdout; 521 return stdout;
489 } else { 522 } else {
490 FILE *file = fopen(name, "wb"); 523 FILE *file = fopen(name, "wb");
491 if (!file) 524 if (!file)
492 fatal("Failed to output file %s", name); 525 fatal("Failed to output file %s", name);
493 return file; 526 return file;
494 } 527 }
495 } 528 }
496 529
530 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
531 static void high_img_upshift(vpx_image_t *dst, vpx_image_t *src,
532 int input_shift) {
533 const int offset = input_shift > 0 ? (1 << (input_shift - 1)) : 0;
534 int plane;
535 if (dst->d_w != src->d_w || dst->d_h != src->d_h ||
536 dst->x_chroma_shift != src->x_chroma_shift ||
537 dst->y_chroma_shift != src->y_chroma_shift ||
538 dst->fmt != src->fmt || input_shift < 0) {
539 fatal("Unsupported image conversion");
540 }
541 switch (src->fmt) {
542 case VPX_IMG_FMT_I42016:
543 case VPX_IMG_FMT_I42216:
544 case VPX_IMG_FMT_I44416:
545 break;
546 default:
547 fatal("Unsupported image conversion");
548 break;
549 }
550 for (plane = 0; plane < 3; plane++) {
551 int w = src->d_w;
552 int h = src->d_h;
553 int x, y;
554 if (plane) {
555 w >>= src->x_chroma_shift;
556 h >>= src->y_chroma_shift;
557 }
558 for (y = 0; y < h; y++) {
559 uint16_t *p_src = (uint16_t *)(src->planes[plane] +
560 y * src->stride[plane]);
561 uint16_t *p_dst = (uint16_t *)(dst->planes[plane] +
562 y * dst->stride[plane]);
563 for (x = 0; x < w; x++)
564 *p_dst++ = (*p_src++ << input_shift) + offset;
565 }
566 }
567 }
568
569 static void low_img_upshift(vpx_image_t *dst, vpx_image_t *src,
570 int input_shift) {
571 const int offset = input_shift > 0 ? (1 << (input_shift - 1)) : 0;
572 int plane;
573 if (dst->d_w != src->d_w || dst->d_h != src->d_h ||
574 dst->x_chroma_shift != src->x_chroma_shift ||
575 dst->y_chroma_shift != src->y_chroma_shift ||
576 dst->fmt != src->fmt + VPX_IMG_FMT_HIGHBITDEPTH ||
577 input_shift < 0) {
578 fatal("Unsupported image conversion");
579 }
580 switch (src->fmt) {
581 case VPX_IMG_FMT_I420:
582 case VPX_IMG_FMT_I422:
583 case VPX_IMG_FMT_I444:
584 break;
585 default:
586 fatal("Unsupported image conversion");
587 break;
588 }
589 for (plane = 0; plane < 3; plane++) {
590 int w = src->d_w;
591 int h = src->d_h;
592 int x, y;
593 if (plane) {
594 w >>= src->x_chroma_shift;
595 h >>= src->y_chroma_shift;
596 }
597 for (y = 0; y < h; y++) {
598 uint8_t *p_src = src->planes[plane] + y * src->stride[plane];
599 uint16_t *p_dst = (uint16_t *)(dst->planes[plane] +
600 y * dst->stride[plane]);
601 for (x = 0; x < w; x++) {
602 *p_dst++ = (*p_src++ << input_shift) + offset;
603 }
604 }
605 }
606 }
607
608 static void img_upshift(vpx_image_t *dst, vpx_image_t *src,
609 int input_shift) {
610 if (src->fmt & VPX_IMG_FMT_HIGHBITDEPTH) {
611 high_img_upshift(dst, src, input_shift);
612 } else {
613 low_img_upshift(dst, src, input_shift);
614 }
615 }
616
617 static void high_img_downshift(vpx_image_t *dst, vpx_image_t *src,
618 int down_shift) {
619 int plane;
620 if (dst->d_w != src->d_w || dst->d_h != src->d_h ||
621 dst->x_chroma_shift != src->x_chroma_shift ||
622 dst->y_chroma_shift != src->y_chroma_shift ||
623 dst->fmt != src->fmt || down_shift < 0) {
624 fatal("Unsupported image conversion");
625 }
626 switch (src->fmt) {
627 case VPX_IMG_FMT_I42016:
628 case VPX_IMG_FMT_I42216:
629 case VPX_IMG_FMT_I44416:
630 break;
631 default:
632 fatal("Unsupported image conversion");
633 break;
634 }
635 for (plane = 0; plane < 3; plane++) {
636 int w = src->d_w;
637 int h = src->d_h;
638 int x, y;
639 if (plane) {
640 w >>= src->x_chroma_shift;
641 h >>= src->y_chroma_shift;
642 }
643 for (y = 0; y < h; y++) {
644 uint16_t *p_src = (uint16_t *)(src->planes[plane] +
645 y * src->stride[plane]);
646 uint16_t *p_dst = (uint16_t *)(dst->planes[plane] +
647 y * dst->stride[plane]);
648 for (x = 0; x < w; x++)
649 *p_dst++ = *p_src++ >> down_shift;
650 }
651 }
652 }
653
654 static void low_img_downshift(vpx_image_t *dst, vpx_image_t *src,
655 int down_shift) {
656 int plane;
657 if (dst->d_w != src->d_w || dst->d_h != src->d_h ||
658 dst->x_chroma_shift != src->x_chroma_shift ||
659 dst->y_chroma_shift != src->y_chroma_shift ||
660 src->fmt != dst->fmt + VPX_IMG_FMT_HIGHBITDEPTH ||
661 down_shift < 0) {
662 fatal("Unsupported image conversion");
663 }
664 switch (dst->fmt) {
665 case VPX_IMG_FMT_I420:
666 case VPX_IMG_FMT_I422:
667 case VPX_IMG_FMT_I444:
668 break;
669 default:
670 fatal("Unsupported image conversion");
671 break;
672 }
673 for (plane = 0; plane < 3; plane++) {
674 int w = src->d_w;
675 int h = src->d_h;
676 int x, y;
677 if (plane) {
678 w >>= src->x_chroma_shift;
679 h >>= src->y_chroma_shift;
680 }
681 for (y = 0; y < h; y++) {
682 uint16_t *p_src = (uint16_t *)(src->planes[plane] +
683 y * src->stride[plane]);
684 uint8_t *p_dst = dst->planes[plane] + y * dst->stride[plane];
685 for (x = 0; x < w; x++) {
686 *p_dst++ = *p_src++ >> down_shift;
687 }
688 }
689 }
690 }
691
692 static void img_downshift(vpx_image_t *dst, vpx_image_t *src,
693 int down_shift) {
694 if (dst->fmt & VPX_IMG_FMT_HIGHBITDEPTH) {
695 high_img_downshift(dst, src, down_shift);
696 } else {
697 low_img_downshift(dst, src, down_shift);
698 }
699 }
700 #endif
701
497 int main_loop(int argc, const char **argv_) { 702 int main_loop(int argc, const char **argv_) {
498 vpx_codec_ctx_t decoder; 703 vpx_codec_ctx_t decoder;
499 char *fn = NULL; 704 char *fn = NULL;
500 int i; 705 int i;
501 uint8_t *buf = NULL; 706 uint8_t *buf = NULL;
502 size_t bytes_in_buffer = 0, buffer_size = 0; 707 size_t bytes_in_buffer = 0, buffer_size = 0;
503 FILE *infile; 708 FILE *infile;
504 int frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0; 709 int frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0;
505 int do_md5 = 0, progress = 0; 710 int do_md5 = 0, progress = 0;
506 int stop_after = 0, postproc = 0, summary = 0, quiet = 1; 711 int stop_after = 0, postproc = 0, summary = 0, quiet = 1;
507 int arg_skip = 0; 712 int arg_skip = 0;
508 int ec_enabled = 0; 713 int ec_enabled = 0;
509 int keep_going = 0; 714 int keep_going = 0;
510 const VpxInterface *interface = NULL; 715 const VpxInterface *interface = NULL;
511 const VpxInterface *fourcc_interface = NULL; 716 const VpxInterface *fourcc_interface = NULL;
512 uint64_t dx_time = 0; 717 uint64_t dx_time = 0;
513 struct arg arg; 718 struct arg arg;
514 char **argv, **argi, **argj; 719 char **argv, **argi, **argj;
515 720
516 int single_file; 721 int single_file;
517 int use_y4m = 1; 722 int use_y4m = 1;
518 int opt_yv12 = 0; 723 int opt_yv12 = 0;
519 int opt_i420 = 0; 724 int opt_i420 = 0;
520 vpx_codec_dec_cfg_t cfg = {0, 0, 0}; 725 vpx_codec_dec_cfg_t cfg = {0, 0, 0};
726 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
727 int output_bit_depth = 0;
728 #endif
521 #if CONFIG_VP8_DECODER 729 #if CONFIG_VP8_DECODER
522 vp8_postproc_cfg_t vp8_pp_cfg = {0}; 730 vp8_postproc_cfg_t vp8_pp_cfg = {0};
523 int vp8_dbg_color_ref_frame = 0; 731 int vp8_dbg_color_ref_frame = 0;
524 int vp8_dbg_color_mb_modes = 0; 732 int vp8_dbg_color_mb_modes = 0;
525 int vp8_dbg_color_b_modes = 0; 733 int vp8_dbg_color_b_modes = 0;
526 int vp8_dbg_display_mv = 0; 734 int vp8_dbg_display_mv = 0;
527 #endif 735 #endif
528 int frames_corrupted = 0; 736 int frames_corrupted = 0;
529 int dec_flags = 0; 737 int dec_flags = 0;
530 int do_scale = 0; 738 int do_scale = 0;
531 vpx_image_t *scaled_img = NULL; 739 vpx_image_t *scaled_img = NULL;
740 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
741 vpx_image_t *img_shifted = NULL;
742 #endif
532 int frame_avail, got_data; 743 int frame_avail, got_data;
533 int num_external_frame_buffers = 0; 744 int num_external_frame_buffers = 0;
534 struct ExternalFrameBufferList ext_fb_list = {0, NULL}; 745 struct ExternalFrameBufferList ext_fb_list = {0, NULL};
535 746
536 const char *outfile_pattern = NULL; 747 const char *outfile_pattern = NULL;
537 char outfile_name[PATH_MAX] = {0}; 748 char outfile_name[PATH_MAX] = {0};
538 FILE *outfile = NULL; 749 FILE *outfile = NULL;
539 750
540 MD5Context md5_ctx; 751 MD5Context md5_ctx;
541 unsigned char md5_digest[16]; 752 unsigned char md5_digest[16];
(...skipping 20 matching lines...) Expand all
562 if (!interface) 773 if (!interface)
563 die("Error: Unrecognized argument (%s) to --codec\n", arg.val); 774 die("Error: Unrecognized argument (%s) to --codec\n", arg.val);
564 } else if (arg_match(&arg, &looparg, argi)) { 775 } else if (arg_match(&arg, &looparg, argi)) {
565 // no-op 776 // no-op
566 } else if (arg_match(&arg, &outputfile, argi)) 777 } else if (arg_match(&arg, &outputfile, argi))
567 outfile_pattern = arg.val; 778 outfile_pattern = arg.val;
568 else if (arg_match(&arg, &use_yv12, argi)) { 779 else if (arg_match(&arg, &use_yv12, argi)) {
569 use_y4m = 0; 780 use_y4m = 0;
570 flipuv = 1; 781 flipuv = 1;
571 opt_yv12 = 1; 782 opt_yv12 = 1;
783 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
784 output_bit_depth = 8; // For yv12 8-bit depth output is assumed
785 #endif
572 } else if (arg_match(&arg, &use_i420, argi)) { 786 } else if (arg_match(&arg, &use_i420, argi)) {
573 use_y4m = 0; 787 use_y4m = 0;
574 flipuv = 0; 788 flipuv = 0;
575 opt_i420 = 1; 789 opt_i420 = 1;
576 } else if (arg_match(&arg, &rawvideo, argi)) { 790 } else if (arg_match(&arg, &rawvideo, argi)) {
577 use_y4m = 0; 791 use_y4m = 0;
578 } else if (arg_match(&arg, &flipuvarg, argi)) 792 } else if (arg_match(&arg, &flipuvarg, argi))
579 flipuv = 1; 793 flipuv = 1;
580 else if (arg_match(&arg, &noblitarg, argi)) 794 else if (arg_match(&arg, &noblitarg, argi))
581 noblit = 1; 795 noblit = 1;
(...skipping 10 matching lines...) Expand all
592 else if (arg_match(&arg, &summaryarg, argi)) 806 else if (arg_match(&arg, &summaryarg, argi))
593 summary = 1; 807 summary = 1;
594 else if (arg_match(&arg, &threadsarg, argi)) 808 else if (arg_match(&arg, &threadsarg, argi))
595 cfg.threads = arg_parse_uint(&arg); 809 cfg.threads = arg_parse_uint(&arg);
596 else if (arg_match(&arg, &verbosearg, argi)) 810 else if (arg_match(&arg, &verbosearg, argi))
597 quiet = 0; 811 quiet = 0;
598 else if (arg_match(&arg, &scalearg, argi)) 812 else if (arg_match(&arg, &scalearg, argi))
599 do_scale = 1; 813 do_scale = 1;
600 else if (arg_match(&arg, &fb_arg, argi)) 814 else if (arg_match(&arg, &fb_arg, argi))
601 num_external_frame_buffers = arg_parse_uint(&arg); 815 num_external_frame_buffers = arg_parse_uint(&arg);
602 816 else if (arg_match(&arg, &continuearg, argi))
817 keep_going = 1;
818 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
819 else if (arg_match(&arg, &outbitdeptharg, argi)) {
820 output_bit_depth = arg_parse_uint(&arg);
821 }
822 #endif
603 #if CONFIG_VP8_DECODER 823 #if CONFIG_VP8_DECODER
604 else if (arg_match(&arg, &addnoise_level, argi)) { 824 else if (arg_match(&arg, &addnoise_level, argi)) {
605 postproc = 1; 825 postproc = 1;
606 vp8_pp_cfg.post_proc_flag |= VP8_ADDNOISE; 826 vp8_pp_cfg.post_proc_flag |= VP8_ADDNOISE;
607 vp8_pp_cfg.noise_level = arg_parse_uint(&arg); 827 vp8_pp_cfg.noise_level = arg_parse_uint(&arg);
608 } else if (arg_match(&arg, &demacroblock_level, argi)) { 828 } else if (arg_match(&arg, &demacroblock_level, argi)) {
609 postproc = 1; 829 postproc = 1;
610 vp8_pp_cfg.post_proc_flag |= VP8_DEMACROBLOCK; 830 vp8_pp_cfg.post_proc_flag |= VP8_DEMACROBLOCK;
611 vp8_pp_cfg.deblocking_level = arg_parse_uint(&arg); 831 vp8_pp_cfg.deblocking_level = arg_parse_uint(&arg);
612 } else if (arg_match(&arg, &deblock, argi)) { 832 } else if (arg_match(&arg, &deblock, argi)) {
(...skipping 29 matching lines...) Expand all
642 vp8_dbg_color_b_modes = flags; 862 vp8_dbg_color_b_modes = flags;
643 } 863 }
644 } else if (arg_match(&arg, &pp_disp_mvs, argi)) { 864 } else if (arg_match(&arg, &pp_disp_mvs, argi)) {
645 unsigned int flags = arg_parse_int(&arg); 865 unsigned int flags = arg_parse_int(&arg);
646 if (flags) { 866 if (flags) {
647 postproc = 1; 867 postproc = 1;
648 vp8_dbg_display_mv = flags; 868 vp8_dbg_display_mv = flags;
649 } 869 }
650 } else if (arg_match(&arg, &error_concealment, argi)) { 870 } else if (arg_match(&arg, &error_concealment, argi)) {
651 ec_enabled = 1; 871 ec_enabled = 1;
652 } else if (arg_match(&arg, &continuearg, argi)) {
653 keep_going = 1;
654 } 872 }
655 873 #endif // CONFIG_VP8_DECODER
656 #endif
657 else 874 else
658 argj++; 875 argj++;
659 } 876 }
660 877
661 /* Check for unrecognized options */ 878 /* Check for unrecognized options */
662 for (argi = argv; *argi; argi++) 879 for (argi = argv; *argi; argi++)
663 if (argi[0][0] == '-' && strlen(argi[0]) > 1) 880 if (argi[0][0] == '-' && strlen(argi[0]) > 1)
664 die("Error: Unrecognized option %s\n", *argi); 881 die("Error: Unrecognized option %s\n", *argi);
665 882
666 /* Handle non-option arguments */ 883 /* Handle non-option arguments */
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 if (vpx_codec_control(&decoder, VP9D_GET_DISPLAY_SIZE, 1099 if (vpx_codec_control(&decoder, VP9D_GET_DISPLAY_SIZE,
883 display_size)) { 1100 display_size)) {
884 // As last resort use size of first frame as display size. 1101 // As last resort use size of first frame as display size.
885 display_width = img->d_w; 1102 display_width = img->d_w;
886 display_height = img->d_h; 1103 display_height = img->d_h;
887 } else { 1104 } else {
888 display_width = display_size[0]; 1105 display_width = display_size[0];
889 display_height = display_size[1]; 1106 display_height = display_size[1];
890 } 1107 }
891 } 1108 }
892 scaled_img = vpx_img_alloc(NULL, VPX_IMG_FMT_I420, display_width, 1109 scaled_img = vpx_img_alloc(NULL, img->fmt, display_width,
893 display_height, 16); 1110 display_height, 16);
894 scaled_img->bit_depth = img->bit_depth; 1111 scaled_img->bit_depth = img->bit_depth;
895 } 1112 }
896 1113
897 if (img->d_w != scaled_img->d_w || img->d_h != scaled_img->d_h) { 1114 if (img->d_w != scaled_img->d_w || img->d_h != scaled_img->d_h) {
898 #if CONFIG_LIBYUV 1115 #if CONFIG_LIBYUV
899 vpx_image_scale(img, scaled_img, kFilterBox); 1116 vpx_image_scale(img, scaled_img, kFilterBox);
900 img = scaled_img; 1117 img = scaled_img;
901 #else 1118 #else
902 fprintf(stderr, "Failed to scale output frame: %s.\n" 1119 fprintf(stderr, "Failed to scale output frame: %s.\n"
903 "Scaling is disabled in this configuration. " 1120 "Scaling is disabled in this configuration. "
904 "To enable scaling, configure with --enable-libyuv\n", 1121 "To enable scaling, configure with --enable-libyuv\n",
905 vpx_codec_error(&decoder)); 1122 vpx_codec_error(&decoder));
906 return EXIT_FAILURE; 1123 return EXIT_FAILURE;
907 #endif 1124 #endif
908 } 1125 }
909 } 1126 }
1127 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
1128 // Default to codec bit depth if output bit depth not set
1129 if (!output_bit_depth) {
1130 output_bit_depth = img->bit_depth;
1131 }
1132 // Shift up or down if necessary
1133 if (output_bit_depth != img->bit_depth) {
1134 if (!img_shifted) {
1135 if (output_bit_depth == 8) {
1136 img_shifted = vpx_img_alloc(
1137 NULL, img->fmt - VPX_IMG_FMT_HIGHBITDEPTH,
1138 img->d_w, img->d_h, 16);
1139 } else {
1140 img_shifted = vpx_img_alloc(
1141 NULL, img->fmt | VPX_IMG_FMT_HIGHBITDEPTH,
1142 img->d_w, img->d_h, 16);
1143 }
1144 img_shifted->bit_depth = output_bit_depth;
1145 }
1146 if (output_bit_depth > img->bit_depth) {
1147 img_upshift(img_shifted, img, output_bit_depth - img->bit_depth);
1148 } else {
1149 img_downshift(img_shifted, img, img->bit_depth - output_bit_depth);
1150 }
1151 img = img_shifted;
1152 }
1153 #endif
910 1154
911 if (single_file) { 1155 if (single_file) {
912 if (use_y4m) { 1156 if (use_y4m) {
913 char buf[Y4M_BUFFER_SIZE] = {0}; 1157 char buf[Y4M_BUFFER_SIZE] = {0};
914 size_t len = 0; 1158 size_t len = 0;
915 if (frame_out == 1) { 1159 if (frame_out == 1) {
916 // Y4M file header 1160 // Y4M file header
917 len = y4m_write_file_header(buf, sizeof(buf), 1161 len = y4m_write_file_header(buf, sizeof(buf),
918 vpx_input_ctx.width, 1162 vpx_input_ctx.width,
919 vpx_input_ctx.height, 1163 vpx_input_ctx.height,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 1250
1007 #if CONFIG_WEBM_IO 1251 #if CONFIG_WEBM_IO
1008 if (input.vpx_input_ctx->file_type == FILE_TYPE_WEBM) 1252 if (input.vpx_input_ctx->file_type == FILE_TYPE_WEBM)
1009 webm_free(input.webm_ctx); 1253 webm_free(input.webm_ctx);
1010 #endif 1254 #endif
1011 1255
1012 if (input.vpx_input_ctx->file_type != FILE_TYPE_WEBM) 1256 if (input.vpx_input_ctx->file_type != FILE_TYPE_WEBM)
1013 free(buf); 1257 free(buf);
1014 1258
1015 if (scaled_img) vpx_img_free(scaled_img); 1259 if (scaled_img) vpx_img_free(scaled_img);
1260 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
1261 if (img_shifted) vpx_img_free(img_shifted);
1262 #endif
1016 1263
1017 for (i = 0; i < ext_fb_list.num_external_frame_buffers; ++i) { 1264 for (i = 0; i < ext_fb_list.num_external_frame_buffers; ++i) {
1018 free(ext_fb_list.ext_fb[i].data); 1265 free(ext_fb_list.ext_fb[i].data);
1019 } 1266 }
1020 free(ext_fb_list.ext_fb); 1267 free(ext_fb_list.ext_fb);
1021 1268
1022 fclose(infile); 1269 fclose(infile);
1023 free(argv); 1270 free(argv);
1024 1271
1025 return frames_corrupted ? EXIT_FAILURE : EXIT_SUCCESS; 1272 return frames_corrupted ? EXIT_FAILURE : EXIT_SUCCESS;
(...skipping 13 matching lines...) Expand all
1039 if (arg_match(&arg, &looparg, argi)) { 1286 if (arg_match(&arg, &looparg, argi)) {
1040 loops = arg_parse_uint(&arg); 1287 loops = arg_parse_uint(&arg);
1041 break; 1288 break;
1042 } 1289 }
1043 } 1290 }
1044 free(argv); 1291 free(argv);
1045 for (i = 0; !error && i < loops; i++) 1292 for (i = 0; !error && i < loops; i++)
1046 error = main_loop(argc, argv_); 1293 error = main_loop(argc, argv_);
1047 return error; 1294 return error;
1048 } 1295 }
OLDNEW
« no previous file with comments | « source/libvpx/vpx_scale/yv12config.h ('k') | source/libvpx/vpxenc.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698