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

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

Issue 394353005: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 5 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/generic/yv12config.c ('k') | source/libvpx/vpxenc.h » ('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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 static const arg_def_t looparg = ARG_DEF(NULL, "loops", 1, 48 static const arg_def_t looparg = ARG_DEF(NULL, "loops", 1,
49 "Number of times to decode the file"); 49 "Number of times to decode the file");
50 static const arg_def_t codecarg = ARG_DEF(NULL, "codec", 1, 50 static const arg_def_t codecarg = ARG_DEF(NULL, "codec", 1,
51 "Codec to use"); 51 "Codec to use");
52 static const arg_def_t use_yv12 = ARG_DEF(NULL, "yv12", 0, 52 static const arg_def_t use_yv12 = ARG_DEF(NULL, "yv12", 0,
53 "Output raw YV12 frames"); 53 "Output raw YV12 frames");
54 static const arg_def_t use_i420 = ARG_DEF(NULL, "i420", 0, 54 static const arg_def_t use_i420 = ARG_DEF(NULL, "i420", 0,
55 "Output raw I420 frames"); 55 "Output raw I420 frames");
56 static const arg_def_t flipuvarg = ARG_DEF(NULL, "flipuv", 0, 56 static const arg_def_t flipuvarg = ARG_DEF(NULL, "flipuv", 0,
57 "Flip the chroma planes in the output "); 57 "Flip the chroma planes in the output ");
58 static const arg_def_t rawvideo = ARG_DEF(NULL, "rawvideo", 0,
59 "Output raw YUV frames");
58 static const arg_def_t noblitarg = ARG_DEF(NULL, "noblit", 0, 60 static const arg_def_t noblitarg = ARG_DEF(NULL, "noblit", 0,
59 "Don't process the decoded frames"); 61 "Don't process the decoded frames");
60 static const arg_def_t progressarg = ARG_DEF(NULL, "progress", 0, 62 static const arg_def_t progressarg = ARG_DEF(NULL, "progress", 0,
61 "Show progress after each frame dec odes"); 63 "Show progress after each frame dec odes");
62 static const arg_def_t limitarg = ARG_DEF(NULL, "limit", 1, 64 static const arg_def_t limitarg = ARG_DEF(NULL, "limit", 1,
63 "Stop decoding after n frames"); 65 "Stop decoding after n frames");
64 static const arg_def_t skiparg = ARG_DEF(NULL, "skip", 1, 66 static const arg_def_t skiparg = ARG_DEF(NULL, "skip", 1,
65 "Skip the first n input frames"); 67 "Skip the first n input frames");
66 static const arg_def_t postprocarg = ARG_DEF(NULL, "postproc", 0, 68 static const arg_def_t postprocarg = ARG_DEF(NULL, "postproc", 0,
67 "Postprocess decoded frames"); 69 "Postprocess decoded frames");
(...skipping 12 matching lines...) Expand all
80 static const arg_def_t continuearg = 82 static const arg_def_t continuearg =
81 ARG_DEF("k", "keep-going", 0, "(debug) Continue decoding after error"); 83 ARG_DEF("k", "keep-going", 0, "(debug) Continue decoding after error");
82 84
83 static const arg_def_t fb_arg = 85 static const arg_def_t fb_arg =
84 ARG_DEF(NULL, "frame-buffers", 1, "Number of frame buffers to use"); 86 ARG_DEF(NULL, "frame-buffers", 1, "Number of frame buffers to use");
85 87
86 static const arg_def_t md5arg = ARG_DEF(NULL, "md5", 0, 88 static const arg_def_t md5arg = ARG_DEF(NULL, "md5", 0,
87 "Compute the MD5 sum of the decoded fram e"); 89 "Compute the MD5 sum of the decoded fram e");
88 90
89 static const arg_def_t *all_args[] = { 91 static const arg_def_t *all_args[] = {
90 &codecarg, &use_yv12, &use_i420, &flipuvarg, &noblitarg, 92 &codecarg, &use_yv12, &use_i420, &flipuvarg, &rawvideo, &noblitarg,
91 &progressarg, &limitarg, &skiparg, &postprocarg, &summaryarg, &outputfile, 93 &progressarg, &limitarg, &skiparg, &postprocarg, &summaryarg, &outputfile,
92 &threadsarg, &verbosearg, &scalearg, &fb_arg, 94 &threadsarg, &verbosearg, &scalearg, &fb_arg,
93 &md5arg, &error_concealment, &continuearg, 95 &md5arg, &error_concealment, &continuearg,
94 NULL 96 NULL
95 }; 97 };
96 98
97 #if CONFIG_VP8_DECODER 99 #if CONFIG_VP8_DECODER
98 static const arg_def_t addnoise_level = ARG_DEF(NULL, "noise-level", 1, 100 static const arg_def_t addnoise_level = ARG_DEF(NULL, "noise-level", 1,
99 "Enable VP8 postproc add noise") ; 101 "Enable VP8 postproc add noise") ;
100 static const arg_def_t deblock = ARG_DEF(NULL, "deblock", 0, 102 static const arg_def_t deblock = ARG_DEF(NULL, "deblock", 0,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 "\n\t%%<n> - Frame number, zero padded to <n> places (1..9)" 161 "\n\t%%<n> - Frame number, zero padded to <n> places (1..9)"
160 "\n\n Pattern arguments are only supported in conjunction " 162 "\n\n Pattern arguments are only supported in conjunction "
161 "with the --yv12 and\n --i420 options. If the -o option is " 163 "with the --yv12 and\n --i420 options. If the -o option is "
162 "not specified, the output will be\n directed to stdout.\n" 164 "not specified, the output will be\n directed to stdout.\n"
163 ); 165 );
164 fprintf(stderr, "\nIncluded decoders:\n\n"); 166 fprintf(stderr, "\nIncluded decoders:\n\n");
165 167
166 for (i = 0; i < get_vpx_decoder_count(); ++i) { 168 for (i = 0; i < get_vpx_decoder_count(); ++i) {
167 const VpxInterface *const decoder = get_vpx_decoder_by_index(i); 169 const VpxInterface *const decoder = get_vpx_decoder_by_index(i);
168 fprintf(stderr, " %-6s - %s\n", 170 fprintf(stderr, " %-6s - %s\n",
169 decoder->name, vpx_codec_iface_name(decoder->interface())); 171 decoder->name, vpx_codec_iface_name(decoder->codec_interface()));
170 } 172 }
171 173
172 exit(EXIT_FAILURE); 174 exit(EXIT_FAILURE);
173 } 175 }
174 176
175 static int raw_read_frame(FILE *infile, uint8_t **buffer, 177 static int raw_read_frame(FILE *infile, uint8_t **buffer,
176 size_t *bytes_read, size_t *buffer_size) { 178 size_t *bytes_read, size_t *buffer_size) {
177 char raw_hdr[RAW_FRAME_HDR_SZ]; 179 char raw_hdr[RAW_FRAME_HDR_SZ];
178 size_t frame_size = 0; 180 size_t frame_size = 0;
179 181
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 vpx_codec_stream_info_t si; 281 vpx_codec_stream_info_t si;
280 282
281 si.sz = sizeof(si); 283 si.sz = sizeof(si);
282 284
283 if (fread(buf, 1, 32, input->file) == 32) { 285 if (fread(buf, 1, 32, input->file) == 32) {
284 int i; 286 int i;
285 287
286 if (mem_get_le32(buf) < 256 * 1024 * 1024) { 288 if (mem_get_le32(buf) < 256 * 1024 * 1024) {
287 for (i = 0; i < get_vpx_decoder_count(); ++i) { 289 for (i = 0; i < get_vpx_decoder_count(); ++i) {
288 const VpxInterface *const decoder = get_vpx_decoder_by_index(i); 290 const VpxInterface *const decoder = get_vpx_decoder_by_index(i);
289 if (!vpx_codec_peek_stream_info(decoder->interface(), 291 if (!vpx_codec_peek_stream_info(decoder->codec_interface(),
290 buf + 4, 32 - 4, &si)) { 292 buf + 4, 32 - 4, &si)) {
291 is_raw = 1; 293 is_raw = 1;
292 input->fourcc = decoder->fourcc; 294 input->fourcc = decoder->fourcc;
293 input->width = si.w; 295 input->width = si.w;
294 input->height = si.h; 296 input->height = si.h;
295 input->framerate.numerator = 30; 297 input->framerate.numerator = 30;
296 input->framerate.denominator = 1; 298 input->framerate.denominator = 1;
297 break; 299 break;
298 } 300 }
299 } 301 }
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 int ec_enabled = 0; 502 int ec_enabled = 0;
501 int keep_going = 0; 503 int keep_going = 0;
502 const VpxInterface *interface = NULL; 504 const VpxInterface *interface = NULL;
503 const VpxInterface *fourcc_interface = NULL; 505 const VpxInterface *fourcc_interface = NULL;
504 uint64_t dx_time = 0; 506 uint64_t dx_time = 0;
505 struct arg arg; 507 struct arg arg;
506 char **argv, **argi, **argj; 508 char **argv, **argi, **argj;
507 509
508 int single_file; 510 int single_file;
509 int use_y4m = 1; 511 int use_y4m = 1;
512 int opt_yv12 = 0;
513 int opt_i420 = 0;
510 vpx_codec_dec_cfg_t cfg = {0}; 514 vpx_codec_dec_cfg_t cfg = {0};
511 #if CONFIG_VP8_DECODER 515 #if CONFIG_VP8_DECODER
512 vp8_postproc_cfg_t vp8_pp_cfg = {0}; 516 vp8_postproc_cfg_t vp8_pp_cfg = {0};
513 int vp8_dbg_color_ref_frame = 0; 517 int vp8_dbg_color_ref_frame = 0;
514 int vp8_dbg_color_mb_modes = 0; 518 int vp8_dbg_color_mb_modes = 0;
515 int vp8_dbg_color_b_modes = 0; 519 int vp8_dbg_color_b_modes = 0;
516 int vp8_dbg_display_mv = 0; 520 int vp8_dbg_display_mv = 0;
517 #endif 521 #endif
518 int frames_corrupted = 0; 522 int frames_corrupted = 0;
519 int dec_flags = 0; 523 int dec_flags = 0;
(...skipping 30 matching lines...) Expand all
550 interface = get_vpx_decoder_by_name(arg.val); 554 interface = get_vpx_decoder_by_name(arg.val);
551 if (!interface) 555 if (!interface)
552 die("Error: Unrecognized argument (%s) to --codec\n", arg.val); 556 die("Error: Unrecognized argument (%s) to --codec\n", arg.val);
553 } else if (arg_match(&arg, &looparg, argi)) { 557 } else if (arg_match(&arg, &looparg, argi)) {
554 // no-op 558 // no-op
555 } else if (arg_match(&arg, &outputfile, argi)) 559 } else if (arg_match(&arg, &outputfile, argi))
556 outfile_pattern = arg.val; 560 outfile_pattern = arg.val;
557 else if (arg_match(&arg, &use_yv12, argi)) { 561 else if (arg_match(&arg, &use_yv12, argi)) {
558 use_y4m = 0; 562 use_y4m = 0;
559 flipuv = 1; 563 flipuv = 1;
564 opt_yv12 = 1;
560 } else if (arg_match(&arg, &use_i420, argi)) { 565 } else if (arg_match(&arg, &use_i420, argi)) {
561 use_y4m = 0; 566 use_y4m = 0;
562 flipuv = 0; 567 flipuv = 0;
568 opt_i420 = 1;
569 } else if (arg_match(&arg, &rawvideo, argi)) {
570 use_y4m = 0;
563 } else if (arg_match(&arg, &flipuvarg, argi)) 571 } else if (arg_match(&arg, &flipuvarg, argi))
564 flipuv = 1; 572 flipuv = 1;
565 else if (arg_match(&arg, &noblitarg, argi)) 573 else if (arg_match(&arg, &noblitarg, argi))
566 noblit = 1; 574 noblit = 1;
567 else if (arg_match(&arg, &progressarg, argi)) 575 else if (arg_match(&arg, &progressarg, argi))
568 progress = 1; 576 progress = 1;
569 else if (arg_match(&arg, &limitarg, argi)) 577 else if (arg_match(&arg, &limitarg, argi))
570 stop_after = arg_parse_uint(&arg); 578 stop_after = arg_parse_uint(&arg);
571 else if (arg_match(&arg, &skiparg, argi)) 579 else if (arg_match(&arg, &skiparg, argi))
572 arg_skip = arg_parse_uint(&arg); 580 arg_skip = arg_parse_uint(&arg);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 if (interface && fourcc_interface && interface != fourcc_interface) 729 if (interface && fourcc_interface && interface != fourcc_interface)
722 warn("Header indicates codec: %s\n", fourcc_interface->name); 730 warn("Header indicates codec: %s\n", fourcc_interface->name);
723 else 731 else
724 interface = fourcc_interface; 732 interface = fourcc_interface;
725 733
726 if (!interface) 734 if (!interface)
727 interface = get_vpx_decoder_by_index(0); 735 interface = get_vpx_decoder_by_index(0);
728 736
729 dec_flags = (postproc ? VPX_CODEC_USE_POSTPROC : 0) | 737 dec_flags = (postproc ? VPX_CODEC_USE_POSTPROC : 0) |
730 (ec_enabled ? VPX_CODEC_USE_ERROR_CONCEALMENT : 0); 738 (ec_enabled ? VPX_CODEC_USE_ERROR_CONCEALMENT : 0);
731 if (vpx_codec_dec_init(&decoder, interface->interface(), &cfg, dec_flags)) { 739 if (vpx_codec_dec_init(&decoder, interface->codec_interface(),
740 &cfg, dec_flags)) {
732 fprintf(stderr, "Failed to initialize decoder: %s\n", 741 fprintf(stderr, "Failed to initialize decoder: %s\n",
733 vpx_codec_error(&decoder)); 742 vpx_codec_error(&decoder));
734 return EXIT_FAILURE; 743 return EXIT_FAILURE;
735 } 744 }
736 745
737 if (!quiet) 746 if (!quiet)
738 fprintf(stderr, "%s\n", decoder.name); 747 fprintf(stderr, "%s\n", decoder.name);
739 748
740 #if CONFIG_VP8_DECODER 749 #if CONFIG_VP8_DECODER
741 750
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 // As last resort use size of first frame as display size. 877 // As last resort use size of first frame as display size.
869 display_width = img->d_w; 878 display_width = img->d_w;
870 display_height = img->d_h; 879 display_height = img->d_h;
871 } else { 880 } else {
872 display_width = display_size[0]; 881 display_width = display_size[0];
873 display_height = display_size[1]; 882 display_height = display_size[1];
874 } 883 }
875 } 884 }
876 scaled_img = vpx_img_alloc(NULL, VPX_IMG_FMT_I420, display_width, 885 scaled_img = vpx_img_alloc(NULL, VPX_IMG_FMT_I420, display_width,
877 display_height, 16); 886 display_height, 16);
887 scaled_img->bit_depth = img->bit_depth;
878 } 888 }
879 889
880 if (img->d_w != scaled_img->d_w || img->d_h != scaled_img->d_h) { 890 if (img->d_w != scaled_img->d_w || img->d_h != scaled_img->d_h) {
881 #if CONFIG_LIBYUV 891 #if CONFIG_LIBYUV
882 vpx_image_scale(img, scaled_img, kFilterBox); 892 vpx_image_scale(img, scaled_img, kFilterBox);
883 img = scaled_img; 893 img = scaled_img;
884 #else 894 #else
885 fprintf(stderr, "Failed to scale output frame: %s.\n" 895 fprintf(stderr, "Failed to scale output frame: %s.\n"
886 "Scaling is disabled in this configuration. " 896 "Scaling is disabled in this configuration. "
887 "To enable scaling, configure with --enable-libyuv\n", 897 "To enable scaling, configure with --enable-libyuv\n",
888 vpx_codec_error(&decoder)); 898 vpx_codec_error(&decoder));
889 return EXIT_FAILURE; 899 return EXIT_FAILURE;
890 #endif 900 #endif
891 } 901 }
892 } 902 }
893 903
894 if (single_file) { 904 if (single_file) {
895 if (use_y4m) { 905 if (use_y4m) {
896 char buf[Y4M_BUFFER_SIZE] = {0}; 906 char buf[Y4M_BUFFER_SIZE] = {0};
897 size_t len = 0; 907 size_t len = 0;
898 if (frame_out == 1) { 908 if (frame_out == 1) {
899 // Y4M file header 909 // Y4M file header
900 len = y4m_write_file_header(buf, sizeof(buf), 910 len = y4m_write_file_header(buf, sizeof(buf),
901 vpx_input_ctx.width, 911 vpx_input_ctx.width,
902 vpx_input_ctx.height, 912 vpx_input_ctx.height,
903 &vpx_input_ctx.framerate, 913 &vpx_input_ctx.framerate,
904 img->fmt, 8); 914 img->fmt, img->bit_depth);
905 if (do_md5) { 915 if (do_md5) {
906 MD5Update(&md5_ctx, (md5byte *)buf, (unsigned int)len); 916 MD5Update(&md5_ctx, (md5byte *)buf, (unsigned int)len);
907 } else { 917 } else {
908 fputs(buf, outfile); 918 fputs(buf, outfile);
909 } 919 }
910 } 920 }
911 921
912 // Y4M frame header 922 // Y4M frame header
913 len = y4m_write_frame_header(buf, sizeof(buf)); 923 len = y4m_write_frame_header(buf, sizeof(buf));
914 if (do_md5) { 924 if (do_md5) {
915 MD5Update(&md5_ctx, (md5byte *)buf, (unsigned int)len); 925 MD5Update(&md5_ctx, (md5byte *)buf, (unsigned int)len);
916 } else { 926 } else {
917 fputs(buf, outfile); 927 fputs(buf, outfile);
918 } 928 }
929 } else {
930 if (frame_out == 1) {
931 // Check if --yv12 or --i420 options are consistent with the
932 // bit-stream decoded
933 if (opt_i420) {
934 if (img->fmt != VPX_IMG_FMT_I420 &&
935 img->fmt != VPX_IMG_FMT_I42016) {
936 fprintf(stderr, "Cannot produce i420 output for bit-stream.\n");
937 goto fail;
938 }
939 }
940 if (opt_yv12) {
941 if ((img->fmt != VPX_IMG_FMT_I420 &&
942 img->fmt != VPX_IMG_FMT_YV12) || img->bit_depth != 8) {
943 fprintf(stderr, "Cannot produce yv12 output for bit-stream.\n");
944 goto fail;
945 }
946 }
947 }
919 } 948 }
920 949
921 if (do_md5) { 950 if (do_md5) {
922 update_image_md5(img, planes, &md5_ctx); 951 update_image_md5(img, planes, &md5_ctx);
923 } else { 952 } else {
924 write_image_file(img, planes, outfile); 953 write_image_file(img, planes, outfile);
925 } 954 }
926 } else { 955 } else {
927 generate_filename(outfile_pattern, outfile_name, PATH_MAX, 956 generate_filename(outfile_pattern, outfile_name, PATH_MAX,
928 img->d_w, img->d_h, frame_in); 957 img->d_w, img->d_h, frame_in);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 if (arg_match(&arg, &looparg, argi)) { 1032 if (arg_match(&arg, &looparg, argi)) {
1004 loops = arg_parse_uint(&arg); 1033 loops = arg_parse_uint(&arg);
1005 break; 1034 break;
1006 } 1035 }
1007 } 1036 }
1008 free(argv); 1037 free(argv);
1009 for (i = 0; !error && i < loops; i++) 1038 for (i = 0; !error && i < loops; i++)
1010 error = main_loop(argc, argv_); 1039 error = main_loop(argc, argv_);
1011 return error; 1040 return error;
1012 } 1041 }
OLDNEW
« no previous file with comments | « source/libvpx/vpx_scale/generic/yv12config.c ('k') | source/libvpx/vpxenc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698