Пример #1
0
int print_avi_info(char *fname)
{
    FILE *fp;
    MainAVIHeader avih;
    AVIStreamHeader avish;
    int listlen, len;
    FOURCC fcc;
    fp = fopen(fname, "rb");
    if (fp == NULL) return -1;
    listlen = read_avi_main_header(fp, &avih);
    printf("listlen: %d\n", listlen);
    printf("%s :  ", fname);
    printf("%lu x %lu  ", avih.dwWidth, avih.dwHeight);
    //printf("1us/frame: %lu. -> fps: %g\n", avih.dwMicroSecPerFrame
    //	, 1000000.0/avih.dwMicroSecPerFrame);
    //printf("frames: %lu -> time: %s\n", avih.dwTotalFrames
    //	, format_time((unsigned long)((double)avih.dwTotalFrames * avih.dwMicroSecPerFrame / 1000000))
    //);
    //printf("\n");
    while ((len = read_next_chunk(fp, &fcc)) > 0) {
        printf("--- %s\n", str_fourcc(fcc));
        if (fcc != SYM_LIST) break;
        if (read_avi_stream_header(fp, &avish, len) < 0) break;
        printf("stream:\n");
        printf("fccType: %s\n", str_fourcc(avish.fccType));
        printf("fccHandler: %s (%s)\n", str_fourcc(avish.fccHandler), str_fourcc(avish.dwReserved1));
        printf("rate: %d\n", avish.dwRate);
        printf("\n");
        if (avish.fccType == SYM_VIDS) {
            printf("V: %s ", str_fourcc(avish.fccHandler));
            if (avish.fccHandler != avish.dwReserved1) {
                printf("(%s) ", str_fourcc(avish.dwReserved1));
            }
            printf(" ");
        } else if (avish.fccType == SYM_AUDS) {
            printf("A: %s ", str_acodec(avish.fccHandler));
            if (avish.fccHandler != avish.dwReserved1) {
                printf("(%s) ", str_acodec(avish.dwReserved1));
            }
            printf(" ");
        }
    }
    do {
        int flag = 0;
        DWORD riff_type;
        printf("--- %s\n", str_fourcc(fcc));
        if (fcc == SYM_LIST) {
            riff_type = read_next_sym(fp);
            if (riff_type == -1) {
                printf("?\n");
                return -1;
            }
            if (riff_type == SYM_MOVI) {
                DWORD old = 0;
                int i;
                printf("----- %s\n", str_fourcc(riff_type));
                for (i=0; i</*avih.dwTotalFrames/ */100 && (len = read_next_chunk(fp, &fcc)) >= 0; i++) {
                len = (len + 1)/ 2 * 2;
                fseek(fp, len, SEEK_CUR);
                printf("fcc: %s\n", str_fourcc(fcc));
                printf("fcc&: %s, ", str_fourcc(fcc & 0x0000ffff));
                printf("old: %s\n", str_fourcc(old));
                if (i != 0 && (fcc & 0x0000ffff) != old) {
                    flag = 1;
                    break;
                }
                old = fcc & 0x0000ffff;
            }
            printf("%s", flag?"[I]":"[NI]");
            break;
        } else {
            printf("----- %s..\n", str_fourcc(riff_type));
            fseek(fp, len - sizeof(riff_type), SEEK_CUR);
        }
    } else {
        printf("FOURCC: %s\n", str_fourcc(fcc));
        fseek(fp, len, SEEK_CUR);
    }
} while ((len = read_next_chunk(fp, &fcc)) > 0);
fclose(fp);
printf("\n");
return 0;
}
Пример #2
0
int main(int narg, char **args)
{
  parallelData world;
  initializeMPIWorld(world, &narg, &args);
  parseArgs(narg,args,world);
  if(!flag_with_filters){
    std::cout<<"NO FILTERS!!!"<<std::endl;
    return 1;
  }
  checkFlagsConsistence(world);

  int numberOfFiles = getAndCheckFileNumber(world, inputfileName);
  int fileId = world.myRank%numberOfFiles;

  parallelData fileGroup;
  splitCommunicatorFillNewParallelData(world, fileGroup, fileId);

  std::string dummyString = composeFileName(inputfileName,fileId);
  char * fileName = new char[dummyString.length() + 1];
  std::strcpy(fileName,dummyString.c_str());

  resetMinimaAndMaxima();

  int readings, reminder, maxReadings;
  MPI_Offset disp;
  {
    long long particleTotalNumber = getAndCheckFileNumberOfParticles(fileGroup, fileName);
    long long myparticlesToRead = calcParticlesToRead(fileGroup, particleTotalNumber);

    long long *particlesToRead = new long long[fileGroup.nProc];
    fillNumberParticlesToRead(fileGroup, particlesToRead, myparticlesToRead);

    readings = myparticlesToRead/readLength;
    reminder = myparticlesToRead%readLength;

    disp = findDispForSetView(fileGroup,particlesToRead);

    int maxReadingsFile = findMaxNumberOfReadings(fileGroup,particlesToRead);

    MPI_Allreduce(&maxReadingsFile, &maxReadings, 1, MPI_INT, MPI_MAX, world.comm);

    delete[] particlesToRead;
  }


  MPI_File theFile;
  MPI_File_open(fileGroup.comm, fileName, MPI_MODE_RDONLY, MPI_INFO_NULL , &theFile);
  MPI_File_set_view(theFile, disp, MPI_FLOAT, MPI_FLOAT, (char *) "native", MPI_INFO_NULL);





  for (int i = 0; i < readings; i++){
    read_next_chunk(theFile,readLength, outputfileName, world);
  }
  for (int i = 0; i < maxReadings-readings; i++){
    read_next_chunk(theFile, 0, outputfileName, world);
  }


  read_next_chunk(theFile, reminder, outputfileName, world);


  MPI_File_close(&theFile);

  MPI_Finalize();
  return 0;
}