#include "av_format_identify.h" #define SIZE_BUFF 0xfffffffff//0xffffffffffffffff #include #include #include #include typedef struct buff_inf_h { char *buff; size_t size; }buff_inf; buff_inf *buff_get(char *vfile) { buff_inf *buff_inf_h = (buff_inf *)malloc(sizeof(buff_inf)); FILE *fr = NULL; char *buff_ori = (char *)malloc(sizeof(char)*SIZE_BUFF); char *buff = buff_ori; //memset(buff, 0, sizeof(char)*SIZE_BUFF); if ((fr = fopen(vfile, "rb")) == NULL) { perror("fopen error:"); buff_inf_h->buff = NULL; buff_inf_h->size = 0; return buff_inf_h; } size_t i = 0; while (!feof(fr)) { fread(buff, 1, 1, fr); buff += 1; i++; } buff_inf_h->buff = (char *)malloc(sizeof(char *) * (i-1)); memcpy(buff_inf_h->buff, buff - i, i-1); buff_inf_h->size = i-1; free(buff_ori); buff_ori = NULL; fclose(fr); return buff_inf_h; } int main(int argc, char *argv[]) { char *vfile = argv[1]; buff_inf *buff_inf_h; int ret; int ret_sig = atoi(argv[2]); int sig_show_all = atoi(argv[3]); int sig_choose_all = atoi(argv[4]); size_t size; buff_inf_h = buff_get(vfile); if (buff_inf_h->size == 0) { printf("read file failed.\n"); return -1; } if (sig_choose_all == 0) { int divide_h = 10; int divide_s = 0; int divide_e = 1; size = (buff_inf_h->size / divide_h)*(divide_e - divide_s); ret = AV_container_identify(buff_inf_h->buff + (buff_inf_h->size / divide_h)*divide_s, size); } else { ret = AV_container_identify(buff_inf_h->buff, buff_inf_h->size); } if (sig_show_all == 0) { if (ret != ret_sig) { printf("-----------------data of [%s] is kind of [%d].\n",vfile,ret); printf("size of whole buff is %zd.\n", buff_inf_h->size); if (sig_choose_all == 0) { printf("size of chosen buff is %zd.\n", size); } } } else { printf("-----------------data of [%s] is kind of [%d].\n", vfile, ret); printf("size of whole buff is %zd.\n", buff_inf_h->size); if (sig_choose_all == 0) { printf("size of chosen buff is %zd.\n", size); } } free(buff_inf_h->buff); buff_inf_h->buff = NULL; free(buff_inf_h); buff_inf_h = NULL; return ret; }