From: Austin Yuan Date: Tue, 14 May 2013 02:02:13 +0000 (+0800) Subject: h264encode: fix ftell overflow issue when open large source YUV files X-Git-Tag: libva-1.2.0~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb50b199607fd52d604f84f3e1de75467a8b968e;p=platform%2Fupstream%2Flibva.git h264encode: fix ftell overflow issue when open large source YUV files Change-Id: I30190d4e28bd643f00808a15846e50e8fca28764 Signed-off-by: Austin Yuan --- diff --git a/test/encode/h264encode.c b/test/encode/h264encode.c index eb5d3e9..7bc85bd 100644 --- a/test/encode/h264encode.c +++ b/test/encode/h264encode.c @@ -702,7 +702,9 @@ static int print_help(void) { printf("./h264encode \n"); printf(" -w -h \n"); + printf(" -framecount \n"); printf(" -n \n"); + printf(" if set to 0 and srcyuv is set, the frame count is from srcuv file\n"); printf(" -o \n"); printf(" -f \n"); printf(" --intra_period \n"); @@ -738,8 +740,9 @@ static int process_cmdline(int argc, char *argv[]) {"fourcc", required_argument, NULL, 11 }, {"syncmode", no_argument, NULL, 12 }, {"enablePSNR", no_argument, NULL, 13 }, - {"privt", required_argument, NULL, 14 }, - {"privv", required_argument, NULL, 15 }, + {"prit", required_argument, NULL, 14 }, + {"priv", required_argument, NULL, 15 }, + {"framecount", required_argument, NULL, 16 }, {NULL, no_argument, NULL, 0 }}; int long_index; @@ -752,6 +755,7 @@ static int process_cmdline(int argc, char *argv[]) frame_height = atoi(optarg); break; case 'n': + case 16: frame_count = atoi(optarg); break; case 'f': @@ -843,9 +847,14 @@ static int process_cmdline(int argc, char *argv[]) if (srcyuv_fp == NULL) printf("Open source YUV file %s failed, use auto-generated YUV data\n", srcyuv_fn); else { - fseek(srcyuv_fp, 0L, SEEK_END); - srcyuv_frames = ftell(srcyuv_fp) / (frame_width * frame_height * 1.5); + struct stat tmp; + + fstat(fileno(srcyuv_fp), &tmp); + srcyuv_frames = tmp.st_size / (frame_width * frame_height * 1.5); printf("Source YUV file %s with %llu frames\n", srcyuv_fn, srcyuv_frames); + + if (frame_count == 0) + frame_count = srcyuv_frames; } }