www.pudn.com > eval-1.2.zip > fixyuv.c



#include 
#include 
#include 
#include 

#include "write.h"
#include "stat.h"
#include "read.h"
#include "misc.h"

static data_t D;

int main(int cn, char *cl[])
{
  int n=0, PoB=0; 
  int nof;
  clock_t t = clock();

  if (cn != 6 && cn != 7) {
    puts("fixyuv      [PoB]");
    puts("  sd\t\tsender dump");
    puts("  rd\t\treceiver dump");
    puts("  st\t\tsender trace");
    puts("  in.yuv\tdecoded video");
    puts("  out.yuv\tfixed video");
    puts("  [PoB]\toptional Play-out buffer size [ms]");
    return 0;
  }

  if (cn == 7) {
    PoB = strtoul(cl[6], 0, 10);
    if (PoB < 10 || PoB > 10000) PoB = 10000;
  } 

  if (!strcmp(cl[1], cl[2])) {
    size_t l = strlen(cl[2]);
    while (l--)
      if (ToLower(cl[2][l]) == 's') {
        cl[2][l] = 'r';
        break;
      }
  } 

  if (!ReadDump(cl, &D, 0, 0)) return EXIT_FAILURE;
  /*
   * Workaround for removing frame counting of repeated headers:
   */
  /* D.nF = (D.nF / 13) * 12; // Works for GOP size of 12 */
#ifdef PLAYOUT_TIME_LMTD
	CalcDelay(D.F, D.nF);
#else
  CalcJitter(D.F, D.nF);
#endif
  if (PoB) PoBLoss(&D, PoB);
  if (! (nof = ReOrder(&D, GetNumB(D.F, D.nF)))) return EXIT_FAILURE;
  /* if (!(n = FixYUV(cl, D.F, D.nF - 1))) return EXIT_FAILURE; */
  if (!(n = FixYUV(cl, D.F, nof))) return EXIT_FAILURE;

  free(D.F);
  free(D.P);

  fprintf(stderr, "fixyuv:\t%d frames in total restored (CPU: %lu s)\n", n, (unsigned long) ((clock() - t) / CLOCKS_PER_SEC));

  return 0;
}