]> rtime.felk.cvut.cz Git - frescor/demo.git/blobdiff - src/recorder/ffmpeg.c
recorder: Initialize FRSH before opening of streams
[frescor/demo.git] / src / recorder / ffmpeg.c
index 777637957b25b6b1460cf8e7837ee96470b3f740..18790dc244bf479529433f8423399d1ef611f488 100644 (file)
@@ -1262,9 +1262,10 @@ static int output_packet(AVInputStream *ist, int ist_index,
                     data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
                     /* XXX: allocate picture correctly */
                     avcodec_get_frame_defaults(&picture);
-
                     ret = avcodec_decode_video2(ist->st->codec,
                                                 &picture, &got_picture, &avpkt);
+                   if (picture.key_frame)
+                           printf("*");
                     ist->st->quality= picture.quality;
                     if (ret < 0)
                         goto fail_decode;
@@ -1597,13 +1598,13 @@ print_timing(void)
 {
        static struct timespec start = {0,0};
        struct timespec end, d;
-       static int f = 0;       /* number of frames */
+       static int f = -1;      /* number interframe intevals elapsed */
        double ifi;
        static double ifi_avg=0, ifi_var=0;
 
        clock_gettime(CLOCK_MONOTONIC, &end);
        timespec_subtract(&d, &end, &start);
-       if (f++ == 0)
+       if (f++ < 0)
                goto out;       /* First run */
        ifi = (double)d.tv_sec + 1e-9*d.tv_nsec;
 #define SQ(x) ((x)*(x))        
@@ -4017,7 +4018,6 @@ static const OptionDef options[] = {
 };
 
 #ifdef CONFIG_FFMPEG_WITH_FRSH
-
 void *av_encode_thread(void *arg)
 {
     int ret, terror;
@@ -4025,7 +4025,7 @@ void *av_encode_thread(void *arg)
 
     /* bind this thread to vres */
     thread_id = fosa_thread_self();
-    /* PXW(frsh_thread_bind(disk_vres, thread_id)); */
+    PXW(frsh_thread_bind(disk_vres, thread_id));
 
     ret = av_encode(output_files, nb_output_files,
                    input_files, nb_input_files,
@@ -4043,18 +4043,19 @@ int frsh_stuff()
 
     frsh_rel_time_t disk_budget, disk_period;
 
-    int ret, terror;
+    int ret;
 
-    PXW(frsh_init());
     cpu_budget = fosa_msec_to_rel_time(5);
     cpu_period = fosa_msec_to_rel_time(1000/50);
 
-/* #define DISK_THROUGHPUT 20277LLU /\* units??? probably MB/s *\/ */
-/*     disk_budget = fosa_nsec_to_rel_time(1000000000LLU/\*nsec/s*\/ * 500000 /\*bytes/s*\/ */
-/*                                     / (DISK_THROUGHPUT*1000000) /\* bytes *\/); // is this correct? */
+#if 1
+#define DISK_THROUGHPUT 20277LLU /* units??? probably MB/s */
+    disk_budget = fosa_nsec_to_rel_time(1000000000LLU/*nsec/s*/ * 500000 /*bytes/s*/
+                                       / (DISK_THROUGHPUT*1000000) /* bytes */); // is this correct?
+#else
     disk_budget = fosa_msec_to_rel_time(1);
-    disk_period = fosa_msec_to_rel_time(1000/50);
+#endif
+    disk_period = fosa_msec_to_rel_time(1000/30);
     
     /* Contract negotiation for CPU */
     ret = frsh_contract_init(&cpu_contract);
@@ -4140,6 +4141,14 @@ int main(int argc, char **argv)
 
     show_banner();
 
+#if CONFIG_FFMPEG_WITH_FRSH
+    {
+       int terror;
+       PXW(frsh_init());
+       printf("FRSH initialized\n");
+    }
+#endif
+
     /* parse options */
     parse_options(argc, argv, options, opt_output_file);