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

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

Issue 1019863002: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « source/libvpx/vpx_scale/vpx_scale_asm_offsets.c ('k') | no next file » | 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 static const arg_def_t skiparg = ARG_DEF( 68 static const arg_def_t skiparg = ARG_DEF(
69 NULL, "skip", 1, "Skip the first n input frames"); 69 NULL, "skip", 1, "Skip the first n input frames");
70 static const arg_def_t postprocarg = ARG_DEF( 70 static const arg_def_t postprocarg = ARG_DEF(
71 NULL, "postproc", 0, "Postprocess decoded frames"); 71 NULL, "postproc", 0, "Postprocess decoded frames");
72 static const arg_def_t summaryarg = ARG_DEF( 72 static const arg_def_t summaryarg = ARG_DEF(
73 NULL, "summary", 0, "Show timing summary"); 73 NULL, "summary", 0, "Show timing summary");
74 static const arg_def_t outputfile = ARG_DEF( 74 static const arg_def_t outputfile = ARG_DEF(
75 "o", "output", 1, "Output file name pattern (see below)"); 75 "o", "output", 1, "Output file name pattern (see below)");
76 static const arg_def_t threadsarg = ARG_DEF( 76 static const arg_def_t threadsarg = ARG_DEF(
77 "t", "threads", 1, "Max threads to use"); 77 "t", "threads", 1, "Max threads to use");
78 static const arg_def_t frameparallelarg = ARG_DEF(
79 NULL, "frame-parallel", 0, "Frame parallel decode");
78 static const arg_def_t verbosearg = ARG_DEF( 80 static const arg_def_t verbosearg = ARG_DEF(
79 "v", "verbose", 0, "Show version string"); 81 "v", "verbose", 0, "Show version string");
80 static const arg_def_t error_concealment = ARG_DEF( 82 static const arg_def_t error_concealment = ARG_DEF(
81 NULL, "error-concealment", 0, "Enable decoder error-concealment"); 83 NULL, "error-concealment", 0, "Enable decoder error-concealment");
82 static const arg_def_t scalearg = ARG_DEF( 84 static const arg_def_t scalearg = ARG_DEF(
83 "S", "scale", 0, "Scale output frames uniformly"); 85 "S", "scale", 0, "Scale output frames uniformly");
84 static const arg_def_t continuearg = ARG_DEF( 86 static const arg_def_t continuearg = ARG_DEF(
85 "k", "keep-going", 0, "(debug) Continue decoding after error"); 87 "k", "keep-going", 0, "(debug) Continue decoding after error");
86 static const arg_def_t fb_arg = ARG_DEF( 88 static const arg_def_t fb_arg = ARG_DEF(
87 NULL, "frame-buffers", 1, "Number of frame buffers to use"); 89 NULL, "frame-buffers", 1, "Number of frame buffers to use");
88 static const arg_def_t md5arg = ARG_DEF( 90 static const arg_def_t md5arg = ARG_DEF(
89 NULL, "md5", 0, "Compute the MD5 sum of the decoded frame"); 91 NULL, "md5", 0, "Compute the MD5 sum of the decoded frame");
90 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH 92 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
91 static const arg_def_t outbitdeptharg = ARG_DEF( 93 static const arg_def_t outbitdeptharg = ARG_DEF(
92 NULL, "output-bit-depth", 1, "Output bit-depth for decoded frames"); 94 NULL, "output-bit-depth", 1, "Output bit-depth for decoded frames");
93 #endif 95 #endif
94 96
95 static const arg_def_t *all_args[] = { 97 static const arg_def_t *all_args[] = {
96 &codecarg, &use_yv12, &use_i420, &flipuvarg, &rawvideo, &noblitarg, 98 &codecarg, &use_yv12, &use_i420, &flipuvarg, &rawvideo, &noblitarg,
97 &progressarg, &limitarg, &skiparg, &postprocarg, &summaryarg, &outputfile, 99 &progressarg, &limitarg, &skiparg, &postprocarg, &summaryarg, &outputfile,
98 &threadsarg, &verbosearg, &scalearg, &fb_arg, 100 &threadsarg, &frameparallelarg, &verbosearg, &scalearg, &fb_arg,
99 &md5arg, &error_concealment, &continuearg, 101 &md5arg, &error_concealment, &continuearg,
100 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH 102 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
101 &outbitdeptharg, 103 &outbitdeptharg,
102 #endif 104 #endif
103 NULL 105 NULL
104 }; 106 };
105 107
106 #if CONFIG_VP8_DECODER 108 #if CONFIG_VP8_DECODER
107 static const arg_def_t addnoise_level = ARG_DEF(NULL, "noise-level", 1, 109 static const arg_def_t addnoise_level = ARG_DEF(NULL, "noise-level", 1,
108 "Enable VP8 postproc add noise") ; 110 "Enable VP8 postproc add noise") ;
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 #endif 537 #endif
536 538
537 int main_loop(int argc, const char **argv_) { 539 int main_loop(int argc, const char **argv_) {
538 vpx_codec_ctx_t decoder; 540 vpx_codec_ctx_t decoder;
539 char *fn = NULL; 541 char *fn = NULL;
540 int i; 542 int i;
541 uint8_t *buf = NULL; 543 uint8_t *buf = NULL;
542 size_t bytes_in_buffer = 0, buffer_size = 0; 544 size_t bytes_in_buffer = 0, buffer_size = 0;
543 FILE *infile; 545 FILE *infile;
544 int frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0; 546 int frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0;
545 int do_md5 = 0, progress = 0; 547 int do_md5 = 0, progress = 0, frame_parallel = 0;
546 int stop_after = 0, postproc = 0, summary = 0, quiet = 1; 548 int stop_after = 0, postproc = 0, summary = 0, quiet = 1;
547 int arg_skip = 0; 549 int arg_skip = 0;
548 int ec_enabled = 0; 550 int ec_enabled = 0;
549 int keep_going = 0; 551 int keep_going = 0;
550 const VpxInterface *interface = NULL; 552 const VpxInterface *interface = NULL;
551 const VpxInterface *fourcc_interface = NULL; 553 const VpxInterface *fourcc_interface = NULL;
552 uint64_t dx_time = 0; 554 uint64_t dx_time = 0;
553 struct arg arg; 555 struct arg arg;
554 char **argv, **argi, **argj; 556 char **argv, **argi, **argj;
555 557
(...skipping 12 matching lines...) Expand all
568 int vp8_dbg_color_b_modes = 0; 570 int vp8_dbg_color_b_modes = 0;
569 int vp8_dbg_display_mv = 0; 571 int vp8_dbg_display_mv = 0;
570 #endif 572 #endif
571 int frames_corrupted = 0; 573 int frames_corrupted = 0;
572 int dec_flags = 0; 574 int dec_flags = 0;
573 int do_scale = 0; 575 int do_scale = 0;
574 vpx_image_t *scaled_img = NULL; 576 vpx_image_t *scaled_img = NULL;
575 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH 577 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
576 vpx_image_t *img_shifted = NULL; 578 vpx_image_t *img_shifted = NULL;
577 #endif 579 #endif
578 int frame_avail, got_data; 580 int frame_avail, got_data, flush_decoder = 0;
579 int num_external_frame_buffers = 0; 581 int num_external_frame_buffers = 0;
580 struct ExternalFrameBufferList ext_fb_list = {0, NULL}; 582 struct ExternalFrameBufferList ext_fb_list = {0, NULL};
581 583
582 const char *outfile_pattern = NULL; 584 const char *outfile_pattern = NULL;
583 char outfile_name[PATH_MAX] = {0}; 585 char outfile_name[PATH_MAX] = {0};
584 FILE *outfile = NULL; 586 FILE *outfile = NULL;
585 587
586 MD5Context md5_ctx; 588 MD5Context md5_ctx;
587 unsigned char md5_digest[16]; 589 unsigned char md5_digest[16];
588 590
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 else if (arg_match(&arg, &skiparg, argi)) 637 else if (arg_match(&arg, &skiparg, argi))
636 arg_skip = arg_parse_uint(&arg); 638 arg_skip = arg_parse_uint(&arg);
637 else if (arg_match(&arg, &postprocarg, argi)) 639 else if (arg_match(&arg, &postprocarg, argi))
638 postproc = 1; 640 postproc = 1;
639 else if (arg_match(&arg, &md5arg, argi)) 641 else if (arg_match(&arg, &md5arg, argi))
640 do_md5 = 1; 642 do_md5 = 1;
641 else if (arg_match(&arg, &summaryarg, argi)) 643 else if (arg_match(&arg, &summaryarg, argi))
642 summary = 1; 644 summary = 1;
643 else if (arg_match(&arg, &threadsarg, argi)) 645 else if (arg_match(&arg, &threadsarg, argi))
644 cfg.threads = arg_parse_uint(&arg); 646 cfg.threads = arg_parse_uint(&arg);
647 #if CONFIG_VP9_DECODER
648 else if (arg_match(&arg, &frameparallelarg, argi))
649 frame_parallel = 1;
650 #endif
645 else if (arg_match(&arg, &verbosearg, argi)) 651 else if (arg_match(&arg, &verbosearg, argi))
646 quiet = 0; 652 quiet = 0;
647 else if (arg_match(&arg, &scalearg, argi)) 653 else if (arg_match(&arg, &scalearg, argi))
648 do_scale = 1; 654 do_scale = 1;
649 else if (arg_match(&arg, &fb_arg, argi)) 655 else if (arg_match(&arg, &fb_arg, argi))
650 num_external_frame_buffers = arg_parse_uint(&arg); 656 num_external_frame_buffers = arg_parse_uint(&arg);
651 else if (arg_match(&arg, &continuearg, argi)) 657 else if (arg_match(&arg, &continuearg, argi))
652 keep_going = 1; 658 keep_going = 1;
653 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH 659 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH
654 else if (arg_match(&arg, &outbitdeptharg, argi)) { 660 else if (arg_match(&arg, &outbitdeptharg, argi)) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 fourcc_interface = get_vpx_decoder_by_fourcc(vpx_input_ctx.fourcc); 793 fourcc_interface = get_vpx_decoder_by_fourcc(vpx_input_ctx.fourcc);
788 if (interface && fourcc_interface && interface != fourcc_interface) 794 if (interface && fourcc_interface && interface != fourcc_interface)
789 warn("Header indicates codec: %s\n", fourcc_interface->name); 795 warn("Header indicates codec: %s\n", fourcc_interface->name);
790 else 796 else
791 interface = fourcc_interface; 797 interface = fourcc_interface;
792 798
793 if (!interface) 799 if (!interface)
794 interface = get_vpx_decoder_by_index(0); 800 interface = get_vpx_decoder_by_index(0);
795 801
796 dec_flags = (postproc ? VPX_CODEC_USE_POSTPROC : 0) | 802 dec_flags = (postproc ? VPX_CODEC_USE_POSTPROC : 0) |
797 (ec_enabled ? VPX_CODEC_USE_ERROR_CONCEALMENT : 0); 803 (ec_enabled ? VPX_CODEC_USE_ERROR_CONCEALMENT : 0) |
804 (frame_parallel ? VPX_CODEC_USE_FRAME_THREADING : 0);
798 if (vpx_codec_dec_init(&decoder, interface->codec_interface(), 805 if (vpx_codec_dec_init(&decoder, interface->codec_interface(),
799 &cfg, dec_flags)) { 806 &cfg, dec_flags)) {
800 fprintf(stderr, "Failed to initialize decoder: %s\n", 807 fprintf(stderr, "Failed to initialize decoder: %s\n",
801 vpx_codec_error(&decoder)); 808 vpx_codec_error(&decoder));
802 return EXIT_FAILURE; 809 return EXIT_FAILURE;
803 } 810 }
804 811
805 if (!quiet) 812 if (!quiet)
806 fprintf(stderr, "%s\n", decoder.name); 813 fprintf(stderr, "%s\n", decoder.name);
807 814
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 } 868 }
862 869
863 frame_avail = 1; 870 frame_avail = 1;
864 got_data = 0; 871 got_data = 0;
865 872
866 /* Decode file */ 873 /* Decode file */
867 while (frame_avail || got_data) { 874 while (frame_avail || got_data) {
868 vpx_codec_iter_t iter = NULL; 875 vpx_codec_iter_t iter = NULL;
869 vpx_image_t *img; 876 vpx_image_t *img;
870 struct vpx_usec_timer timer; 877 struct vpx_usec_timer timer;
871 int corrupted; 878 int corrupted = 0;
872 879
873 frame_avail = 0; 880 frame_avail = 0;
874 if (!stop_after || frame_in < stop_after) { 881 if (!stop_after || frame_in < stop_after) {
875 if (!read_frame(&input, &buf, &bytes_in_buffer, &buffer_size)) { 882 if (!read_frame(&input, &buf, &bytes_in_buffer, &buffer_size)) {
876 frame_avail = 1; 883 frame_avail = 1;
877 frame_in++; 884 frame_in++;
878 885
879 vpx_usec_timer_start(&timer); 886 vpx_usec_timer_start(&timer);
880 887
881 if (vpx_codec_decode(&decoder, buf, (unsigned int)bytes_in_buffer, 888 if (vpx_codec_decode(&decoder, buf, (unsigned int)bytes_in_buffer,
882 NULL, 0)) { 889 NULL, 0)) {
883 const char *detail = vpx_codec_error_detail(&decoder); 890 const char *detail = vpx_codec_error_detail(&decoder);
884 warn("Failed to decode frame %d: %s", 891 warn("Failed to decode frame %d: %s",
885 frame_in, vpx_codec_error(&decoder)); 892 frame_in, vpx_codec_error(&decoder));
886 893
887 if (detail) 894 if (detail)
888 warn("Additional information: %s", detail); 895 warn("Additional information: %s", detail);
889 if (!keep_going) 896 if (!keep_going)
890 goto fail; 897 goto fail;
891 } 898 }
892 899
893 vpx_usec_timer_mark(&timer); 900 vpx_usec_timer_mark(&timer);
894 dx_time += vpx_usec_timer_elapsed(&timer); 901 dx_time += vpx_usec_timer_elapsed(&timer);
902 } else {
903 flush_decoder = 1;
895 } 904 }
905 } else {
906 flush_decoder = 1;
896 } 907 }
897 908
898 vpx_usec_timer_start(&timer); 909 vpx_usec_timer_start(&timer);
899 910
911 if (flush_decoder) {
912 // Flush the decoder in frame parallel decode.
913 if (vpx_codec_decode(&decoder, NULL, 0, NULL, 0)) {
914 warn("Failed to flush decoder: %s", vpx_codec_error(&decoder));
915 }
916 }
917
900 got_data = 0; 918 got_data = 0;
901 if ((img = vpx_codec_get_frame(&decoder, &iter))) { 919 if ((img = vpx_codec_get_frame(&decoder, &iter))) {
902 ++frame_out; 920 ++frame_out;
903 got_data = 1; 921 got_data = 1;
904 } 922 }
905 923
906 vpx_usec_timer_mark(&timer); 924 vpx_usec_timer_mark(&timer);
907 dx_time += (unsigned int)vpx_usec_timer_elapsed(&timer); 925 dx_time += (unsigned int)vpx_usec_timer_elapsed(&timer);
908 926
909 if (vpx_codec_control(&decoder, VP8D_GET_FRAME_CORRUPTED, &corrupted)) { 927 if (!frame_parallel &&
928 vpx_codec_control(&decoder, VP8D_GET_FRAME_CORRUPTED, &corrupted)) {
910 warn("Failed VP8_GET_FRAME_CORRUPTED: %s", vpx_codec_error(&decoder)); 929 warn("Failed VP8_GET_FRAME_CORRUPTED: %s", vpx_codec_error(&decoder));
911 if (!keep_going) 930 if (!keep_going)
912 goto fail; 931 goto fail;
913 } 932 }
914 frames_corrupted += corrupted; 933 frames_corrupted += corrupted;
915 934
916 if (progress) 935 if (progress)
917 show_progress(frame_in, frame_out, dx_time); 936 show_progress(frame_in, frame_out, dx_time);
918 937
919 if (!noblit && img) { 938 if (!noblit && img) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 if (arg_match(&arg, &looparg, argi)) { 1148 if (arg_match(&arg, &looparg, argi)) {
1130 loops = arg_parse_uint(&arg); 1149 loops = arg_parse_uint(&arg);
1131 break; 1150 break;
1132 } 1151 }
1133 } 1152 }
1134 free(argv); 1153 free(argv);
1135 for (i = 0; !error && i < loops; i++) 1154 for (i = 0; !error && i < loops; i++)
1136 error = main_loop(argc, argv_); 1155 error = main_loop(argc, argv_);
1137 return error; 1156 return error;
1138 } 1157 }
OLDNEW
« no previous file with comments | « source/libvpx/vpx_scale/vpx_scale_asm_offsets.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698