FILE *fpFailList = NULL;
static int mmfile_get_file_infomation(void *data, void *user_data, bool file_test);
+static int mmfile_get_video_frame(void *data, void *accurate, bool file_test);
+
inline static int mm_file_is_little_endian(void)
{
if (S_ISDIR(statbuf.st_mode)) {
mmfile_get_file_names(argv[1], mmfile_get_file_infomation, NULL);
} else {
- mmfile_get_file_infomation(argv[1], NULL, file_test);
+ if (argv[2] == NULL)
+ mmfile_get_file_infomation(argv[1], NULL, file_test);
+ else
+ mmfile_get_video_frame(argv[1], argv[2], file_test);
}
if (fpFailList != NULL) {
int audio_track_num = 0;
int video_track_num = 0;
int ret = 0;
- char filename[512];
+ char filename[512] = {0, };
- memset(filename, 0x00, 512);
- memcpy(filename, (char *)data, strlen((char *)data));
+ memset(filename, 0x00, sizeof(filename));
+ SAFE_STRLCPY(filename, (char *)data, sizeof(filename));
MM_TIME_CHECK_START
return 0;
}
+
+static int mmfile_get_video_frame(void *data, void *accurate, bool file_test)
+{
+ int ret = 0;
+ char filename[512] = {0, };
+ char accurate_mode[10] = {0, };
+ void *_frame = NULL;
+ int _frame_size = 0;
+ int width = 0;
+ int height = 0;
+ bool is_accurate = FALSE;
+ unsigned long long time_stamp = 5 * 1000 * 1000; //5sec
+
+ memset(filename, 0x00, sizeof(filename));
+ SAFE_STRLCPY(filename, (char *)data, sizeof(filename));
+
+ memset(accurate_mode, 0x00, sizeof(accurate_mode));
+ SAFE_STRLCPY(accurate_mode, (char *)accurate, sizeof(accurate_mode));
+
+ if (strlen(accurate_mode) > 0) {
+ if (strncmp (accurate_mode, "1", 1) == 0)
+ is_accurate = TRUE;
+ }
+
+ printf("Extracting video frame for [%s] [%llu] accurate [%d]\n", filename, time_stamp, is_accurate);
+
+ if (file_test == TRUE)
+ ret = mm_file_get_video_frame(filename, time_stamp, is_accurate, (unsigned char **)&_frame, &_frame_size, &width, &height);
+ else {
+ unsigned int file_size = 0;
+ unsigned char *buffer = NULL;
+ /* Read file */
+ READ_FROM_FILE(filename, buffer, file_size);
+
+ ret = mm_file_get_video_frame_from_memory(buffer, file_size, time_stamp, is_accurate, (unsigned char **)&_frame, &_frame_size, &width, &height);
+ }
+
+ if (ret != FILEINFO_ERROR_NONE)
+ printf("Failed to mm_file_get_video_frame() error=[%x]\n", ret);
+ else
+ printf("video_frame[%p], video_frame_len = [%d] width = [%d] height = [%d]\n", _frame, _frame_size, width, height);
+
+ return 0;
+}