#include <core/consumer/frame_consumer.h>\r
#include <core/producer/frame_producer.h>\r
\r
-#include <tbb/mutex.h>\r
+#include <tbb/recursive_mutex.h>\r
\r
#if defined(_MSC_VER)\r
#pragma warning (disable : 4244)\r
if(!mutex)\r
return 0;\r
\r
- auto my_mutex = reinterpret_cast<tbb::mutex*>(*mutex);\r
+ auto my_mutex = reinterpret_cast<tbb::recursive_mutex*>(*mutex);\r
\r
switch(op) \r
{ \r
case AV_LOCK_CREATE: \r
{ \r
- *mutex = new tbb::mutex(); \r
+ *mutex = new tbb::recursive_mutex(); \r
break; \r
} \r
case AV_LOCK_OBTAIN: \r
return 0; \r
} \r
\r
-static void sanitize(uint8_t *line)
-{
- while(*line)
- {
- if(*line < 0x08 || (*line > 0x0D && *line < 0x20))
- *line='?';
- line++;
- }
+static void sanitize(uint8_t *line)\r
+{\r
+ while(*line)\r
+ {\r
+ if(*line < 0x08 || (*line > 0x0D && *line < 0x20))\r
+ *line='?';\r
+ line++;\r
+ }\r
}\r
\r
void log_callback(void* ptr, int level, const char* fmt, va_list vl)\r
-{
- static int print_prefix=1;
- static int count;
- static char prev[1024];
- char line[8192];
- static int is_atty;
- AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
- if(level > av_log_get_level())
- return;
- line[0]=0;
-
-#undef fprintf
- if(print_prefix && avc)
- {
- if (avc->parent_log_context_offset)
- {
- AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset);
- if(parent && *parent)
- std::sprintf(line, "[%s @ %p] ", (*parent)->item_name(parent), parent);
- }
- std::sprintf(line + strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr);
- }
-
- std::vsprintf(line + strlen(line), fmt, vl);
-
- print_prefix = strlen(line) && line[strlen(line)-1] == '\n';
-
- //if(print_prefix && !strcmp(line, prev)){
- // count++;
- // if(is_atty==1)
- // fprintf(stderr, " Last message repeated %d times\r", count);
- // return;
- //}
- //if(count>0){
- // fprintf(stderr, " Last message repeated %d times\n", count);
- // count=0;
- //}
- strcpy(prev, line);
- sanitize((uint8_t*)line);
-
- CASPAR_LOG(trace) << L"[FFMPEG] [" << av_clip(level>>3, 0, 6) << L"] " << line;
-
+{\r
+ static int print_prefix=1;\r
+ static int count;\r
+ static char prev[1024];\r
+ char line[8192];\r
+ static int is_atty;\r
+ AVClass* avc= ptr ? *(AVClass**)ptr : NULL;\r
+ if(level > av_log_get_level())\r
+ return;\r
+ line[0]=0;\r
+ \r
+#undef fprintf\r
+ if(print_prefix && avc) \r
+ {\r
+ if (avc->parent_log_context_offset) \r
+ {\r
+ AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset);\r
+ if(parent && *parent)\r
+ std::sprintf(line, "[%s @ %p] ", (*parent)->item_name(parent), parent); \r
+ }\r
+ std::sprintf(line + strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr);\r
+ }\r
+\r
+ std::vsprintf(line + strlen(line), fmt, vl);\r
+\r
+ print_prefix = strlen(line) && line[strlen(line)-1] == '\n';\r
+ \r
+ //if(print_prefix && !strcmp(line, prev)){\r
+ // count++;\r
+ // if(is_atty==1)\r
+ // fprintf(stderr, " Last message repeated %d times\r", count);\r
+ // return;\r
+ //}\r
+ //if(count>0){\r
+ // fprintf(stderr, " Last message repeated %d times\n", count);\r
+ // count=0;\r
+ //}\r
+ strcpy(prev, line);\r
+ sanitize((uint8_t*)line);\r
+ \r
+ CASPAR_LOG(trace) << L"[FFMPEG] [" << av_clip(level>>3, 0, 6) << L"] " << line;\r
+\r
//colored_fputs(av_clip(level>>3, 0, 6), line);\r
}\r
\r
std::vector<safe_ptr<AVFrame>> av_frames;\r
\r
auto packet = std::move(packet_buffer_.front());\r
- packet_buffer_.pop();\r
\r
if(packet)\r
- decode(*packet, av_frames); \r
+ {\r
+ decode(*packet, av_frames); \r
+ packet_buffer_.pop();\r
+ }\r
else\r
{\r
+ bool flush = true;\r
+\r
if(codec_context_->codec->capabilities | CODEC_CAP_DELAY)\r
{\r
- // FIXME: This might cause bad performance.\r
AVPacket pkt = {0};\r
- for(int n = 0; n < 8 && decode(pkt, av_frames); ++n){}\r
+ flush = !decode(pkt, av_frames);\r
}\r
\r
- avcodec_flush_buffers(codec_context_.get());\r
+ if(flush)\r
+ { \r
+ packet_buffer_.pop();\r
+ avcodec_flush_buffers(codec_context_.get());\r
+ }\r
}\r
\r
if(filter_)\r