| OLD | NEW | 
|---|
| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 80 static const arg_def_t postprocarg = ARG_DEF(NULL, "postproc", 0, | 80 static const arg_def_t postprocarg = ARG_DEF(NULL, "postproc", 0, | 
| 81                                      "Postprocess decoded frames"); | 81                                      "Postprocess decoded frames"); | 
| 82 static const arg_def_t summaryarg = ARG_DEF(NULL, "summary", 0, | 82 static const arg_def_t summaryarg = ARG_DEF(NULL, "summary", 0, | 
| 83                                     "Show timing summary"); | 83                                     "Show timing summary"); | 
| 84 static const arg_def_t outputfile = ARG_DEF("o", "output", 1, | 84 static const arg_def_t outputfile = ARG_DEF("o", "output", 1, | 
| 85                                     "Output file name pattern (see below)"); | 85                                     "Output file name pattern (see below)"); | 
| 86 static const arg_def_t threadsarg = ARG_DEF("t", "threads", 1, | 86 static const arg_def_t threadsarg = ARG_DEF("t", "threads", 1, | 
| 87                                     "Max threads to use"); | 87                                     "Max threads to use"); | 
| 88 static const arg_def_t verbosearg = ARG_DEF("v", "verbose", 0, | 88 static const arg_def_t verbosearg = ARG_DEF("v", "verbose", 0, | 
| 89                                   "Show version string"); | 89                                   "Show version string"); | 
|  | 90 static const arg_def_t error_concealment = ARG_DEF(NULL, "error-concealment", 0, | 
|  | 91                                        "Enable decoder error-concealment"); | 
|  | 92 | 
| 90 | 93 | 
| 91 #if CONFIG_MD5 | 94 #if CONFIG_MD5 | 
| 92 static const arg_def_t md5arg = ARG_DEF(NULL, "md5", 0, | 95 static const arg_def_t md5arg = ARG_DEF(NULL, "md5", 0, | 
| 93                                         "Compute the MD5 sum of the decoded fram
      e"); | 96                                         "Compute the MD5 sum of the decoded fram
      e"); | 
| 94 #endif | 97 #endif | 
| 95 static const arg_def_t *all_args[] = | 98 static const arg_def_t *all_args[] = | 
| 96 { | 99 { | 
| 97     &codecarg, &use_yv12, &use_i420, &flipuvarg, &noblitarg, | 100     &codecarg, &use_yv12, &use_i420, &flipuvarg, &noblitarg, | 
| 98     &progressarg, &limitarg, &postprocarg, &summaryarg, &outputfile, | 101     &progressarg, &limitarg, &postprocarg, &summaryarg, &outputfile, | 
| 99     &threadsarg, &verbosearg, | 102     &threadsarg, &verbosearg, | 
| 100 #if CONFIG_MD5 | 103 #if CONFIG_MD5 | 
| 101     &md5arg, | 104     &md5arg, | 
| 102 #endif | 105 #endif | 
|  | 106     &error_concealment, | 
| 103     NULL | 107     NULL | 
| 104 }; | 108 }; | 
| 105 | 109 | 
| 106 #if CONFIG_VP8_DECODER | 110 #if CONFIG_VP8_DECODER | 
| 107 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, | 
| 108                                         "Enable VP8 postproc add noise"); | 112                                         "Enable VP8 postproc add noise"); | 
| 109 static const arg_def_t deblock = ARG_DEF(NULL, "deblock", 0, | 113 static const arg_def_t deblock = ARG_DEF(NULL, "deblock", 0, | 
| 110                                  "Enable VP8 deblocking"); | 114                                  "Enable VP8 deblocking"); | 
| 111 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, | 
| 112         "Enable VP8 demacroblocking, w/ level"); | 116         "Enable VP8 demacroblocking, w/ level"); | 
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 566 static int | 570 static int | 
| 567 file_is_webm(struct input_ctx *input, | 571 file_is_webm(struct input_ctx *input, | 
| 568              unsigned int     *fourcc, | 572              unsigned int     *fourcc, | 
| 569              unsigned int     *width, | 573              unsigned int     *width, | 
| 570              unsigned int     *height, | 574              unsigned int     *height, | 
| 571              unsigned int     *fps_den, | 575              unsigned int     *fps_den, | 
| 572              unsigned int     *fps_num) | 576              unsigned int     *fps_num) | 
| 573 { | 577 { | 
| 574     unsigned int i, n; | 578     unsigned int i, n; | 
| 575     int          track_type = -1; | 579     int          track_type = -1; | 
| 576     uint64_t     tstamp=0; |  | 
| 577 | 580 | 
| 578     nestegg_io io = {nestegg_read_cb, nestegg_seek_cb, nestegg_tell_cb, | 581     nestegg_io io = {nestegg_read_cb, nestegg_seek_cb, nestegg_tell_cb, | 
| 579                      input->infile}; | 582                      input->infile}; | 
| 580     nestegg_video_params params; | 583     nestegg_video_params params; | 
| 581     nestegg_packet * pkt; |  | 
| 582 | 584 | 
| 583     if(nestegg_init(&input->nestegg_ctx, io, NULL)) | 585     if(nestegg_init(&input->nestegg_ctx, io, NULL)) | 
| 584         goto fail; | 586         goto fail; | 
| 585 | 587 | 
| 586     if(nestegg_track_count(input->nestegg_ctx, &n)) | 588     if(nestegg_track_count(input->nestegg_ctx, &n)) | 
| 587         goto fail; | 589         goto fail; | 
| 588 | 590 | 
| 589     for(i=0; i<n; i++) | 591     for(i=0; i<n; i++) | 
| 590     { | 592     { | 
| 591         track_type = nestegg_track_type(input->nestegg_ctx, i); | 593         track_type = nestegg_track_type(input->nestegg_ctx, i); | 
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 695 int main(int argc, const char **argv_) | 697 int main(int argc, const char **argv_) | 
| 696 { | 698 { | 
| 697     vpx_codec_ctx_t          decoder; | 699     vpx_codec_ctx_t          decoder; | 
| 698     char                  *fn = NULL; | 700     char                  *fn = NULL; | 
| 699     int                    i; | 701     int                    i; | 
| 700     uint8_t               *buf = NULL; | 702     uint8_t               *buf = NULL; | 
| 701     size_t                 buf_sz = 0, buf_alloc_sz = 0; | 703     size_t                 buf_sz = 0, buf_alloc_sz = 0; | 
| 702     FILE                  *infile; | 704     FILE                  *infile; | 
| 703     int                    frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0, 
      do_md5 = 0, progress = 0; | 705     int                    frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0, 
      do_md5 = 0, progress = 0; | 
| 704     int                    stop_after = 0, postproc = 0, summary = 0, quiet = 1; | 706     int                    stop_after = 0, postproc = 0, summary = 0, quiet = 1; | 
|  | 707     int                    ec_enabled = 0; | 
| 705     vpx_codec_iface_t       *iface = NULL; | 708     vpx_codec_iface_t       *iface = NULL; | 
| 706     unsigned int           fourcc; | 709     unsigned int           fourcc; | 
| 707     unsigned long          dx_time = 0; | 710     unsigned long          dx_time = 0; | 
| 708     struct arg               arg; | 711     struct arg               arg; | 
| 709     char                   **argv, **argi, **argj; | 712     char                   **argv, **argi, **argj; | 
| 710     const char             *outfile_pattern = 0; | 713     const char             *outfile_pattern = 0; | 
| 711     char                    outfile[PATH_MAX]; | 714     char                    outfile[PATH_MAX]; | 
| 712     int                     single_file; | 715     int                     single_file; | 
| 713     int                     use_y4m = 1; | 716     int                     use_y4m = 1; | 
| 714     unsigned int            width; | 717     unsigned int            width; | 
| 715     unsigned int            height; | 718     unsigned int            height; | 
| 716     unsigned int            fps_den; | 719     unsigned int            fps_den; | 
| 717     unsigned int            fps_num; | 720     unsigned int            fps_num; | 
| 718     void                   *out = NULL; | 721     void                   *out = NULL; | 
| 719     vpx_codec_dec_cfg_t     cfg = {0}; | 722     vpx_codec_dec_cfg_t     cfg = {0}; | 
| 720 #if CONFIG_VP8_DECODER | 723 #if CONFIG_VP8_DECODER | 
| 721     vp8_postproc_cfg_t      vp8_pp_cfg = {0}; | 724     vp8_postproc_cfg_t      vp8_pp_cfg = {0}; | 
| 722     int                     vp8_dbg_color_ref_frame = 0; | 725     int                     vp8_dbg_color_ref_frame = 0; | 
| 723     int                     vp8_dbg_color_mb_modes = 0; | 726     int                     vp8_dbg_color_mb_modes = 0; | 
| 724     int                     vp8_dbg_color_b_modes = 0; | 727     int                     vp8_dbg_color_b_modes = 0; | 
| 725     int                     vp8_dbg_display_mv = 0; | 728     int                     vp8_dbg_display_mv = 0; | 
| 726 #endif | 729 #endif | 
| 727     struct input_ctx        input = {0}; | 730     struct input_ctx        input = {0}; | 
|  | 731     int                     frames_corrupted = 0; | 
|  | 732     int                     dec_flags = 0; | 
| 728 | 733 | 
| 729     /* Parse command line */ | 734     /* Parse command line */ | 
| 730     exec_name = argv_[0]; | 735     exec_name = argv_[0]; | 
| 731     argv = argv_dup(argc - 1, argv_ + 1); | 736     argv = argv_dup(argc - 1, argv_ + 1); | 
| 732 | 737 | 
| 733     for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) | 738     for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) | 
| 734     { | 739     { | 
| 735         memset(&arg, 0, sizeof(arg)); | 740         memset(&arg, 0, sizeof(arg)); | 
| 736         arg.argv_step = 1; | 741         arg.argv_step = 1; | 
| 737 | 742 | 
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 837         } | 842         } | 
| 838         else if (arg_match(&arg, &pp_disp_mvs, argi)) | 843         else if (arg_match(&arg, &pp_disp_mvs, argi)) | 
| 839         { | 844         { | 
| 840             unsigned int flags = arg_parse_int(&arg); | 845             unsigned int flags = arg_parse_int(&arg); | 
| 841             if (flags) | 846             if (flags) | 
| 842             { | 847             { | 
| 843                 postproc = 1; | 848                 postproc = 1; | 
| 844                 vp8_dbg_display_mv = flags; | 849                 vp8_dbg_display_mv = flags; | 
| 845             } | 850             } | 
| 846         } | 851         } | 
|  | 852         else if (arg_match(&arg, &error_concealment, argi)) | 
|  | 853         { | 
|  | 854             ec_enabled = 1; | 
|  | 855         } | 
| 847 | 856 | 
| 848 #endif | 857 #endif | 
| 849         else | 858         else | 
| 850             argj++; | 859             argj++; | 
| 851     } | 860     } | 
| 852 | 861 | 
| 853     /* Check for unrecognized options */ | 862     /* Check for unrecognized options */ | 
| 854     for (argi = argv; *argi; argi++) | 863     for (argi = argv; *argi; argi++) | 
| 855         if (argi[0][0] == '-' && strlen(argi[0]) > 1) | 864         if (argi[0][0] == '-' && strlen(argi[0]) > 1) | 
| 856             die("Error: Unrecognized option %s\n", *argi); | 865             die("Error: Unrecognized option %s\n", *argi); | 
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 957 | 966 | 
| 958             if (iface && iface != ivf_iface) | 967             if (iface && iface != ivf_iface) | 
| 959                 fprintf(stderr, "Notice -- IVF header indicates codec: %s\n", | 968                 fprintf(stderr, "Notice -- IVF header indicates codec: %s\n", | 
| 960                         ifaces[i].name); | 969                         ifaces[i].name); | 
| 961             else | 970             else | 
| 962                 iface = ivf_iface; | 971                 iface = ivf_iface; | 
| 963 | 972 | 
| 964             break; | 973             break; | 
| 965         } | 974         } | 
| 966 | 975 | 
|  | 976     dec_flags = (postproc ? VPX_CODEC_USE_POSTPROC : 0) | | 
|  | 977                 (ec_enabled ? VPX_CODEC_USE_ERROR_CONCEALMENT : 0); | 
| 967     if (vpx_codec_dec_init(&decoder, iface ? iface :  ifaces[0].iface, &cfg, | 978     if (vpx_codec_dec_init(&decoder, iface ? iface :  ifaces[0].iface, &cfg, | 
| 968                            postproc ? VPX_CODEC_USE_POSTPROC : 0)) | 979                            dec_flags)) | 
| 969     { | 980     { | 
| 970         fprintf(stderr, "Failed to initialize decoder: %s\n", vpx_codec_error(&d
      ecoder)); | 981         fprintf(stderr, "Failed to initialize decoder: %s\n", vpx_codec_error(&d
      ecoder)); | 
| 971         return EXIT_FAILURE; | 982         return EXIT_FAILURE; | 
| 972     } | 983     } | 
| 973 | 984 | 
| 974     if (!quiet) | 985     if (!quiet) | 
| 975         fprintf(stderr, "%s\n", decoder.name); | 986         fprintf(stderr, "%s\n", decoder.name); | 
| 976 | 987 | 
| 977 #if CONFIG_VP8_DECODER | 988 #if CONFIG_VP8_DECODER | 
| 978 | 989 | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1011         return EXIT_FAILURE; | 1022         return EXIT_FAILURE; | 
| 1012     } | 1023     } | 
| 1013 #endif | 1024 #endif | 
| 1014 | 1025 | 
| 1015     /* Decode file */ | 1026     /* Decode file */ | 
| 1016     while (!read_frame(&input, &buf, &buf_sz, &buf_alloc_sz)) | 1027     while (!read_frame(&input, &buf, &buf_sz, &buf_alloc_sz)) | 
| 1017     { | 1028     { | 
| 1018         vpx_codec_iter_t  iter = NULL; | 1029         vpx_codec_iter_t  iter = NULL; | 
| 1019         vpx_image_t    *img; | 1030         vpx_image_t    *img; | 
| 1020         struct vpx_usec_timer timer; | 1031         struct vpx_usec_timer timer; | 
|  | 1032         int                   corrupted; | 
| 1021 | 1033 | 
| 1022         vpx_usec_timer_start(&timer); | 1034         vpx_usec_timer_start(&timer); | 
| 1023 | 1035 | 
| 1024         if (vpx_codec_decode(&decoder, buf, buf_sz, NULL, 0)) | 1036         if (vpx_codec_decode(&decoder, buf, buf_sz, NULL, 0)) | 
| 1025         { | 1037         { | 
| 1026             const char *detail = vpx_codec_error_detail(&decoder); | 1038             const char *detail = vpx_codec_error_detail(&decoder); | 
| 1027             fprintf(stderr, "Failed to decode frame: %s\n", vpx_codec_error(&dec
      oder)); | 1039             fprintf(stderr, "Failed to decode frame: %s\n", vpx_codec_error(&dec
      oder)); | 
| 1028 | 1040 | 
| 1029             if (detail) | 1041             if (detail) | 
| 1030                 fprintf(stderr, "  Additional information: %s\n", detail); | 1042                 fprintf(stderr, "  Additional information: %s\n", detail); | 
| 1031 | 1043 | 
| 1032             goto fail; | 1044             goto fail; | 
| 1033         } | 1045         } | 
| 1034 | 1046 | 
| 1035         vpx_usec_timer_mark(&timer); | 1047         vpx_usec_timer_mark(&timer); | 
| 1036         dx_time += vpx_usec_timer_elapsed(&timer); | 1048         dx_time += vpx_usec_timer_elapsed(&timer); | 
| 1037 | 1049 | 
| 1038         ++frame_in; | 1050         ++frame_in; | 
| 1039 | 1051 | 
|  | 1052         if (vpx_codec_control(&decoder, VP8D_GET_FRAME_CORRUPTED, &corrupted)) | 
|  | 1053         { | 
|  | 1054             fprintf(stderr, "Failed VP8_GET_FRAME_CORRUPTED: %s\n", | 
|  | 1055                     vpx_codec_error(&decoder)); | 
|  | 1056             goto fail; | 
|  | 1057         } | 
|  | 1058         frames_corrupted += corrupted; | 
|  | 1059 | 
| 1040         if ((img = vpx_codec_get_frame(&decoder, &iter))) | 1060         if ((img = vpx_codec_get_frame(&decoder, &iter))) | 
| 1041             ++frame_out; | 1061             ++frame_out; | 
| 1042 | 1062 | 
| 1043         if (progress) | 1063         if (progress) | 
| 1044             show_progress(frame_in, frame_out, dx_time); | 1064             show_progress(frame_in, frame_out, dx_time); | 
| 1045 | 1065 | 
| 1046         if (!noblit) | 1066         if (!noblit) | 
| 1047         { | 1067         { | 
| 1048             if (img) | 1068             if (img) | 
| 1049             { | 1069             { | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1095         if (stop_after && frame_in >= stop_after) | 1115         if (stop_after && frame_in >= stop_after) | 
| 1096             break; | 1116             break; | 
| 1097     } | 1117     } | 
| 1098 | 1118 | 
| 1099     if (summary || progress) | 1119     if (summary || progress) | 
| 1100     { | 1120     { | 
| 1101         show_progress(frame_in, frame_out, dx_time); | 1121         show_progress(frame_in, frame_out, dx_time); | 
| 1102         fprintf(stderr, "\n"); | 1122         fprintf(stderr, "\n"); | 
| 1103     } | 1123     } | 
| 1104 | 1124 | 
|  | 1125     if (frames_corrupted) | 
|  | 1126         fprintf(stderr, "WARNING: %d frames corrupted.\n",frames_corrupted); | 
|  | 1127 | 
| 1105 fail: | 1128 fail: | 
| 1106 | 1129 | 
| 1107     if (vpx_codec_destroy(&decoder)) | 1130     if (vpx_codec_destroy(&decoder)) | 
| 1108     { | 1131     { | 
| 1109         fprintf(stderr, "Failed to destroy decoder: %s\n", vpx_codec_error(&deco
      der)); | 1132         fprintf(stderr, "Failed to destroy decoder: %s\n", vpx_codec_error(&deco
      der)); | 
| 1110         return EXIT_FAILURE; | 1133         return EXIT_FAILURE; | 
| 1111     } | 1134     } | 
| 1112 | 1135 | 
| 1113     if (single_file && !noblit) | 1136     if (single_file && !noblit) | 
| 1114         out_close(out, outfile, do_md5); | 1137         out_close(out, outfile, do_md5); | 
| 1115 | 1138 | 
| 1116     if(input.nestegg_ctx) | 1139     if(input.nestegg_ctx) | 
| 1117         nestegg_destroy(input.nestegg_ctx); | 1140         nestegg_destroy(input.nestegg_ctx); | 
| 1118     if(input.kind != WEBM_FILE) | 1141     if(input.kind != WEBM_FILE) | 
| 1119         free(buf); | 1142         free(buf); | 
| 1120     fclose(infile); | 1143     fclose(infile); | 
| 1121     free(argv); | 1144     free(argv); | 
| 1122 | 1145 | 
| 1123     return EXIT_SUCCESS; | 1146     return frames_corrupted ? EXIT_FAILURE : EXIT_SUCCESS; | 
| 1124 } | 1147 } | 
| OLD | NEW | 
|---|