hardware/intel/libva
Revision | cb50b199607fd52d604f84f3e1de75467a8b968e (tree) |
---|---|
Zeit | 2013-06-25 14:57:14 |
Autor | Austin Yuan <shengquan.yuan@inte...> |
Commiter | Xiang, Haihao |
h264encode: fix ftell overflow issue when open large source YUV files
Change-Id: I30190d4e28bd643f00808a15846e50e8fca28764
Signed-off-by: Austin Yuan <shengquan.yuan@intel.com>
@@ -702,7 +702,9 @@ static int print_help(void) | ||
702 | 702 | { |
703 | 703 | printf("./h264encode <options>\n"); |
704 | 704 | printf(" -w <width> -h <height>\n"); |
705 | + printf(" -framecount <frame number>\n"); | |
705 | 706 | printf(" -n <frame number>\n"); |
707 | + printf(" if set to 0 and srcyuv is set, the frame count is from srcuv file\n"); | |
706 | 708 | printf(" -o <coded file>\n"); |
707 | 709 | printf(" -f <frame rate>\n"); |
708 | 710 | printf(" --intra_period <number>\n"); |
@@ -738,8 +740,9 @@ static int process_cmdline(int argc, char *argv[]) | ||
738 | 740 | {"fourcc", required_argument, NULL, 11 }, |
739 | 741 | {"syncmode", no_argument, NULL, 12 }, |
740 | 742 | {"enablePSNR", no_argument, NULL, 13 }, |
741 | - {"privt", required_argument, NULL, 14 }, | |
742 | - {"privv", required_argument, NULL, 15 }, | |
743 | + {"prit", required_argument, NULL, 14 }, | |
744 | + {"priv", required_argument, NULL, 15 }, | |
745 | + {"framecount", required_argument, NULL, 16 }, | |
743 | 746 | {NULL, no_argument, NULL, 0 }}; |
744 | 747 | int long_index; |
745 | 748 |
@@ -752,6 +755,7 @@ static int process_cmdline(int argc, char *argv[]) | ||
752 | 755 | frame_height = atoi(optarg); |
753 | 756 | break; |
754 | 757 | case 'n': |
758 | + case 16: | |
755 | 759 | frame_count = atoi(optarg); |
756 | 760 | break; |
757 | 761 | case 'f': |
@@ -843,9 +847,14 @@ static int process_cmdline(int argc, char *argv[]) | ||
843 | 847 | if (srcyuv_fp == NULL) |
844 | 848 | printf("Open source YUV file %s failed, use auto-generated YUV data\n", srcyuv_fn); |
845 | 849 | else { |
846 | - fseek(srcyuv_fp, 0L, SEEK_END); | |
847 | - srcyuv_frames = ftell(srcyuv_fp) / (frame_width * frame_height * 1.5); | |
850 | + struct stat tmp; | |
851 | + | |
852 | + fstat(fileno(srcyuv_fp), &tmp); | |
853 | + srcyuv_frames = tmp.st_size / (frame_width * frame_height * 1.5); | |
848 | 854 | printf("Source YUV file %s with %llu frames\n", srcyuv_fn, srcyuv_frames); |
855 | + | |
856 | + if (frame_count == 0) | |
857 | + frame_count = srcyuv_frames; | |
849 | 858 | } |
850 | 859 | } |
851 | 860 |