Ejemplo n.º 1
0
static gavl_edl_track_t * copy_tracks(const gavl_edl_track_t * src, int len)
  {
  int i;
  gavl_edl_track_t * ret;
  ret = calloc(len, sizeof(*ret));
  
  /* Copy integers */
  memcpy(ret, src, len * sizeof(*ret));
  
  for(i = 0; i < len; i++)
    {
    /* Copy pointers */
    gavl_metadata_init(&ret[i].metadata);
    
    gavl_metadata_copy(&ret[i].metadata, &src[i].metadata);
    
    ret[i].audio_streams =
      copy_streams(src[i].audio_streams,
                   src[i].num_audio_streams);
    ret[i].video_streams =
      copy_streams(src[i].video_streams,
                   src[i].num_video_streams);
    ret[i].text_streams =
      copy_streams(src[i].text_streams,
                   src[i].num_text_streams);
    ret[i].overlay_streams =
      copy_streams(src[i].overlay_streams,
                   src[i].num_overlay_streams);
    }
  return ret;
  }
bool implicit_report(bip_context* c)
{
    /* Create report file */
    FILE* report = fopen("reports/implicit.tex", "w");
    if(report == NULL) {
        return false;
    }

    /* Write preamble */
    bool success = insert_file("latex/header.tex", report);
    if(!success) {
        return false;
    }
    fprintf(report, "\n");

    /* Write header */
    fprintf(report, "\\section{%s}\n\n", "Implicit Enumeration");
    fprintf(report, "\\noindent{\\huge %s.} \\\\[0.4cm]\n",
            "Binary Integer Programming");
    fprintf(report, "{\\LARGE %s.}\\\\[0.4cm]\n", "Operation Research");
    fprintf(report, "\\HRule \\\\[0.5cm]\n");

    /* Write description */
    fprintf(report, "\\indent ");
    success = insert_file("latex/preamble.tex", report);
    if(!success) {
        return false;
    }

    /* Write first section */
    fprintf(report, "\\\\[0.5cm]\n\\noindent{\\Large Details:}\n");
    fprintf(report, "\\begin{compactitem}\n");
    fprintf(report, "\\item %s : \\textsc{%s}. \n",
            "Executed on", get_current_time());
    fprintf(report, "\\item %s : \\textsc{%lf %s}. \n",
            "Execution time", c->execution_time,
            "seconds");
    fprintf(report, "\\item %s : \\textsc{%i %s}. \n",
            "Memory required", c->memory_required,
            "bytes");
    fprintf(report, "\\end{compactitem}\n");
    fprintf(report, "\n");

    /* TOC */
    fprintf(report, "\\newpage\n");
    fprintf(report, "\\tableofcontents\n");
    fprintf(report, "\\newpage\n");
    fprintf(report, "\n");

    /* Model */
    fprintf(report, "\\section{%s}\n", "Model");
    fprintf(report, "\n");
    imp_model(report, c);
    fprintf(report, "\\end{adjustwidth}\n");
    fprintf(report, "\\newpage\n");
    fprintf(report, "\n");

    /* Write execution */
    fprintf(report, "\\section{%s}\n", "Resolution");
    success = copy_streams(c->report_buffer, report);
    if(!success) {
        return false;
    }

    /* End document */
    fprintf(report, "\\end{document}\n");
    fprintf(report, "\n");

    /* Save & swap buffers */
    int success_file = fflush(report);
    if(success_file == EOF) {
        return false;
    }
    success_file = fclose(c->report_buffer);
    if(success_file == EOF) {
        return false;
    }
    c->report_buffer = report;

    return true;
}