hedgewars/avwrapper/avwrapper.c
branchui-scaling
changeset 15288 c4fd2813b127
parent 14950 00cf807b7faa
equal deleted inserted replaced
13395:0135e64c6c66 15288:c4fd2813b127
    33 #define AVWRAP_DECL __attribute__((visibility("default")))
    33 #define AVWRAP_DECL __attribute__((visibility("default")))
    34 #else
    34 #else
    35 #define AVWRAP_DECL
    35 #define AVWRAP_DECL
    36 #endif
    36 #endif
    37 
    37 
       
    38 #define UNUSED(x) (void)(x)
       
    39 
    38 static AVFormatContext* g_pContainer;
    40 static AVFormatContext* g_pContainer;
    39 static AVOutputFormat* g_pFormat;
    41 static AVOutputFormat* g_pFormat;
    40 static AVStream* g_pAStream;
    42 static AVStream* g_pAStream;
    41 static AVStream* g_pVStream;
    43 static AVStream* g_pVStream;
    42 static AVFrame* g_pAFrame;
    44 static AVFrame* g_pAFrame;
   136 // Function to be called from libav for logging.
   138 // Function to be called from libav for logging.
   137 // Note: libav can call LogCallback from different threads
   139 // Note: libav can call LogCallback from different threads
   138 // (there is mutex in AddFileLogRaw).
   140 // (there is mutex in AddFileLogRaw).
   139 static void LogCallback(void* p, int Level, const char* pFmt, va_list VaArgs)
   141 static void LogCallback(void* p, int Level, const char* pFmt, va_list VaArgs)
   140 {
   142 {
       
   143     UNUSED(p);
       
   144     UNUSED(Level);
       
   145 
   141     char Buffer[1024];
   146     char Buffer[1024];
   142 
   147 
   143     vsnprintf(Buffer, 1024, pFmt, VaArgs);
   148     vsnprintf(Buffer, 1024, pFmt, VaArgs);
   144     AddFileLogRaw(Buffer);
   149     AddFileLogRaw(Buffer);
   145 }
   150 }
   360     if (g_pAStream)
   365     if (g_pAStream)
   361     {
   366     {
   362         VideoTime = (double)g_pVFrame->pts * g_pVStream->time_base.num/g_pVStream->time_base.den;
   367         VideoTime = (double)g_pVFrame->pts * g_pVStream->time_base.num/g_pVStream->time_base.den;
   363         do
   368         do
   364         {
   369         {
       
   370             if (!g_pAFrame)
       
   371                 return FatalError("Error while writing video frame: g_pAFrame does not exist");
   365             AudioTime = (double)g_pAFrame->pts * g_pAStream->time_base.num/g_pAStream->time_base.den;
   372             AudioTime = (double)g_pAFrame->pts * g_pAStream->time_base.num/g_pAStream->time_base.den;
   366             ret = WriteAudioFrame();
   373             ret = WriteAudioFrame();
   367         }
   374         }
   368         while (AudioTime < VideoTime && ret);
   375         while (AudioTime < VideoTime && ret);
   369         if (ret < 0)
   376         if (ret < 0)