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

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

Issue 181493009: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 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 | 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
11 #include <assert.h> 11 #include <assert.h>
12 #include <stdio.h> 12 #include <stdio.h>
13 #include <stdlib.h> 13 #include <stdlib.h>
14 #include <stdarg.h> 14 #include <stdarg.h>
15 #include <string.h> 15 #include <string.h>
16 #include <limits.h> 16 #include <limits.h>
17 17
18 #include "third_party/libyuv/include/libyuv/scale.h" 18 #include "third_party/libyuv/include/libyuv/scale.h"
19 19
20 #include "./args.h" 20 #include "./args.h"
21 #include "./ivfdec.h" 21 #include "./ivfdec.h"
22 22
23 #define VPX_CODEC_DISABLE_COMPAT 1 23 #define VPX_CODEC_DISABLE_COMPAT 1
24 #include "./vpx_config.h" 24 #include "./vpx_config.h"
25 #include "vpx/vpx_decoder.h" 25 #include "vpx/vpx_decoder.h"
26 #include "vpx_ports/mem_ops.h"
26 #include "vpx_ports/vpx_timer.h" 27 #include "vpx_ports/vpx_timer.h"
27 28
28 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER 29 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER
29 #include "vpx/vp8dx.h" 30 #include "vpx/vp8dx.h"
30 #endif 31 #endif
31 32
32 #include "./md5_utils.h" 33 #include "./md5_utils.h"
33 34
34 #include "./tools_common.h" 35 #include "./tools_common.h"
35 #include "./webmdec.h" 36 #include "./webmdec.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 break; 292 break;
292 } 293 }
293 } 294 }
294 } 295 }
295 } 296 }
296 297
297 rewind(input->file); 298 rewind(input->file);
298 return is_raw; 299 return is_raw;
299 } 300 }
300 301
301 void show_progress(int frame_in, int frame_out, unsigned long dx_time) { 302 void show_progress(int frame_in, int frame_out, uint64_t dx_time) {
302 fprintf(stderr, "%d decoded frames/%d showed frames in %lu us (%.2f fps)\r", 303 fprintf(stderr,
304 "%d decoded frames/%d showed frames in %"PRId64" us (%.2f fps)\r",
303 frame_in, frame_out, dx_time, 305 frame_in, frame_out, dx_time,
304 (float)frame_out * 1000000.0 / (float)dx_time); 306 (double)frame_out * 1000000.0 / (double)dx_time);
305 } 307 }
306 308
307 struct ExternalFrameBuffer { 309 struct ExternalFrameBuffer {
308 uint8_t* data; 310 uint8_t* data;
309 size_t size; 311 size_t size;
310 int in_use; 312 int in_use;
311 }; 313 };
312 314
313 struct ExternalFrameBufferList { 315 struct ExternalFrameBufferList {
314 int num_external_frame_buffers; 316 int num_external_frame_buffers;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 FILE *file = fopen(name, "wb"); 477 FILE *file = fopen(name, "wb");
476 if (!file) 478 if (!file)
477 fatal("Failed to output file %s", name); 479 fatal("Failed to output file %s", name);
478 return file; 480 return file;
479 } 481 }
480 } 482 }
481 483
482 int main_loop(int argc, const char **argv_) { 484 int main_loop(int argc, const char **argv_) {
483 vpx_codec_ctx_t decoder; 485 vpx_codec_ctx_t decoder;
484 char *fn = NULL; 486 char *fn = NULL;
487 int i;
485 uint8_t *buf = NULL; 488 uint8_t *buf = NULL;
486 size_t bytes_in_buffer = 0, buffer_size = 0; 489 size_t bytes_in_buffer = 0, buffer_size = 0;
487 FILE *infile; 490 FILE *infile;
488 int frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0; 491 int frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0;
489 int do_md5 = 0, progress = 0; 492 int do_md5 = 0, progress = 0;
490 int stop_after = 0, postproc = 0, summary = 0, quiet = 1; 493 int stop_after = 0, postproc = 0, summary = 0, quiet = 1;
491 int arg_skip = 0; 494 int arg_skip = 0;
492 int ec_enabled = 0; 495 int ec_enabled = 0;
493 const VpxInterface *interface = NULL; 496 const VpxInterface *interface = NULL;
494 const VpxInterface *fourcc_interface = NULL; 497 const VpxInterface *fourcc_interface = NULL;
495 unsigned long dx_time = 0; 498 uint64_t dx_time = 0;
496 struct arg arg; 499 struct arg arg;
497 char **argv, **argi, **argj; 500 char **argv, **argi, **argj;
498 501
499 int single_file; 502 int single_file;
500 int use_y4m = 1; 503 int use_y4m = 1;
501 vpx_codec_dec_cfg_t cfg = {0}; 504 vpx_codec_dec_cfg_t cfg = {0};
502 #if CONFIG_VP8_DECODER 505 #if CONFIG_VP8_DECODER
503 vp8_postproc_cfg_t vp8_pp_cfg = {0}; 506 vp8_postproc_cfg_t vp8_pp_cfg = {0};
504 int vp8_dbg_color_ref_frame = 0; 507 int vp8_dbg_color_ref_frame = 0;
505 int vp8_dbg_color_mb_modes = 0; 508 int vp8_dbg_color_mb_modes = 0;
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 int corrupted; 786 int corrupted;
784 787
785 frame_avail = 0; 788 frame_avail = 0;
786 if (!stop_after || frame_in < stop_after) { 789 if (!stop_after || frame_in < stop_after) {
787 if (!read_frame(&input, &buf, &bytes_in_buffer, &buffer_size)) { 790 if (!read_frame(&input, &buf, &bytes_in_buffer, &buffer_size)) {
788 frame_avail = 1; 791 frame_avail = 1;
789 frame_in++; 792 frame_in++;
790 793
791 vpx_usec_timer_start(&timer); 794 vpx_usec_timer_start(&timer);
792 795
793 if (vpx_codec_decode(&decoder, buf, bytes_in_buffer, NULL, 0)) { 796 if (vpx_codec_decode(&decoder, buf, (unsigned int)bytes_in_buffer,
797 NULL, 0)) {
794 const char *detail = vpx_codec_error_detail(&decoder); 798 const char *detail = vpx_codec_error_detail(&decoder);
795 warn("Failed to decode frame %d: %s", 799 warn("Failed to decode frame %d: %s",
796 frame_in, vpx_codec_error(&decoder)); 800 frame_in, vpx_codec_error(&decoder));
797 801
798 if (detail) 802 if (detail)
799 warn("Additional information: %s", detail); 803 warn("Additional information: %s", detail);
800 goto fail; 804 goto fail;
801 } 805 }
802 806
803 vpx_usec_timer_mark(&timer); 807 vpx_usec_timer_mark(&timer);
804 dx_time += (unsigned int)vpx_usec_timer_elapsed(&timer); 808 dx_time += vpx_usec_timer_elapsed(&timer);
805 } 809 }
806 } 810 }
807 811
808 vpx_usec_timer_start(&timer); 812 vpx_usec_timer_start(&timer);
809 813
810 got_data = 0; 814 got_data = 0;
811 if ((img = vpx_codec_get_frame(&decoder, &iter))) { 815 if ((img = vpx_codec_get_frame(&decoder, &iter))) {
812 ++frame_out; 816 ++frame_out;
813 got_data = 1; 817 got_data = 1;
814 } 818 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 if (use_y4m) { 869 if (use_y4m) {
866 char buf[Y4M_BUFFER_SIZE] = {0}; 870 char buf[Y4M_BUFFER_SIZE] = {0};
867 size_t len = 0; 871 size_t len = 0;
868 if (frame_out == 1) { 872 if (frame_out == 1) {
869 // Y4M file header 873 // Y4M file header
870 len = y4m_write_file_header(buf, sizeof(buf), 874 len = y4m_write_file_header(buf, sizeof(buf),
871 vpx_input_ctx.width, 875 vpx_input_ctx.width,
872 vpx_input_ctx.height, 876 vpx_input_ctx.height,
873 &vpx_input_ctx.framerate, img->fmt); 877 &vpx_input_ctx.framerate, img->fmt);
874 if (do_md5) { 878 if (do_md5) {
875 MD5Update(&md5_ctx, (md5byte *)buf, len); 879 MD5Update(&md5_ctx, (md5byte *)buf, (unsigned int)len);
876 } else { 880 } else {
877 fputs(buf, outfile); 881 fputs(buf, outfile);
878 } 882 }
879 } 883 }
880 884
881 // Y4M frame header 885 // Y4M frame header
882 len = y4m_write_frame_header(buf, sizeof(buf)); 886 len = y4m_write_frame_header(buf, sizeof(buf));
883 if (do_md5) { 887 if (do_md5) {
884 MD5Update(&md5_ctx, (md5byte *)buf, len); 888 MD5Update(&md5_ctx, (md5byte *)buf, (unsigned int)len);
885 } else { 889 } else {
886 fputs(buf, outfile); 890 fputs(buf, outfile);
887 } 891 }
888 } 892 }
889 893
890 if (do_md5) { 894 if (do_md5) {
891 update_image_md5(img, planes, &md5_ctx); 895 update_image_md5(img, planes, &md5_ctx);
892 } else { 896 } else {
893 write_image_file(img, planes, outfile); 897 write_image_file(img, planes, outfile);
894 } 898 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 if (arg_match(&arg, &looparg, argi)) { 973 if (arg_match(&arg, &looparg, argi)) {
970 loops = arg_parse_uint(&arg); 974 loops = arg_parse_uint(&arg);
971 break; 975 break;
972 } 976 }
973 } 977 }
974 free(argv); 978 free(argv);
975 for (i = 0; !error && i < loops; i++) 979 for (i = 0; !error && i < loops; i++)
976 error = main_loop(argc, argv_); 980 error = main_loop(argc, argv_);
977 return error; 981 return error;
978 } 982 }
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