@@ -64,10 +64,14 @@ bool gif_to_jpeg_preencode(const uint8_t *gif_data,
6464 gif->setFrameBuf (frame_buf);
6565 gif->setDrawType (GIF_DRAW_COOKED);
6666
67+ uint64_t total_decode_time_us = 0 ;
68+ uint64_t total_encode_time_us = 0 ;
69+
6770 int delay_ms = 0 ;
6871 while (store.count () < store.maxFrames ()) {
6972 uint64_t start_time_us = esp_timer_get_time ();
7073 if (gif->playFrame (true , &delay_ms)) {
74+ uint64_t end_decode_time_us = esp_timer_get_time ();
7175 // In COOKED mode, RGB888 data starts after the 8-bit palette data (w*h bytes in)
7276 const uint8_t *rgb_data = frame_buf + ((size_t )canvas_width * (size_t )canvas_height);
7377
@@ -88,17 +92,20 @@ bool gif_to_jpeg_preencode(const uint8_t *gif_data,
8892 free (jpeg_buf);
8993 break ;
9094 }
91- ESP_LOGI (TAG, " Frame %d decoded and encoded in %llu us, size %d" , store.count (), esp_timer_get_time () - start_time_us, jpeg_len);
92- // Yield to prevent watchdog timeout during intensive frame processing
93- vTaskDelay (10 / portTICK_PERIOD_MS);
95+ uint64_t end_time_us = esp_timer_get_time ();
96+ total_decode_time_us += end_decode_time_us - start_time_us;
97+ total_encode_time_us += end_time_us - end_decode_time_us;
98+ ESP_LOGI (TAG, " Frame %d decoded in %llu us and encoded in %llu us, size %d" , store.count (), end_decode_time_us - start_time_us, end_time_us - end_decode_time_us, jpeg_len);
9499 }
95100 }
96101
97102 ESP_LOGI (TAG, " Pre-encoded %d frames" , store.count ());
98-
103+ ESP_LOGI (TAG, " Total decode time: %llu us" , total_decode_time_us);
104+ ESP_LOGI (TAG, " Total encode time: %llu us" , total_encode_time_us);
105+ ESP_LOGI (TAG, " Average decode time: %llu us" , total_decode_time_us / store.count ());
106+ ESP_LOGI (TAG, " Average encode time: %llu us" , total_encode_time_us / store.count ());
99107 free (frame_buf);
100108 gif->close ();
101109 delete gif;
102110 return store.count () > 0 ;
103111}
104-
0 commit comments