zoukankan      html  css  js  c++  java
  • VC使用mingw32编译ffmpeg静态库所需文件(一),ffmpegshim.c

    VC使用mingw32编译ffmpeg静态库所需文件(一),ffmpegshim.c

    哈哈,这是我从一些项目里面看到的,这些函数是ffmpeg.a缺少的函数。估计大家会用得上.

    当然我移植的的项目都不需要这些,因为我是用VC编译,所以不存在缺少mingw32里面的函数.

    // ffmpegshim.c
    // this file is part of Context Free
    // ---------------------
    // Copyright (C) 2012 John Horigan - john@glyphic.com
    // Copyright (C) 2000 Free Software Foundation, Inc.
    //
    // This program is free software; you can redistribute it and/or
    // modify it under the terms of the GNU General Public License
    // as published by the Free Software Foundation; either version 2
    // of the License, or (at your option) any later version.
    //
    // This program is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.
    //
    // You should have received a copy of the GNU General Public License
    // along with this program; if not, write to the Free Software
    // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    //
    // John Horigan can be contacted at john@glyphic.com or at
    // John Horigan, 1209 Villa St., Mountain View, CA 94041-1123, USA
    //
    //
    
    #define WIN32_LEAN_AND_MEAN
    #define _CRT_SECURE_NO_WARNINGS
    
    #include <windows.h>
    #include <stdio.h>
    #include <stdarg.h>
    #include <stdlib.h>
    #include <time.h>
    #include <errno.h>
    #include <math.h>
    
    int __cdecl __mingw_vsnprintf(
         char *buffer,
         size_t count,
         const char *format,
         va_list argptr
    )
    {
        return vsnprintf_s(buffer, count, _TRUNCATE, format, argptr);
    }
    
    int __cdecl __ms_vsnprintf(
         char *buffer,
         size_t count,
         const char *format,
         va_list argptr
    )
    {
        return vsnprintf_s(buffer, count, _TRUNCATE, format, argptr);
    }
    
    int __cdecl __mingw_vfprintf(
         FILE *stream,
         const char *format,
         va_list argptr
    )
    {
        return vfprintf_s(stream, format, argptr);
    }
    
    int __cdecl __mingw_vsprintf (char * s, const char * format, va_list arg )
    {
    	return vsprintf (s, format, arg );
    }
    
    #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
      #define DELTA_EPOCH_IN_MICROSECS  11644473600000000Ui64
    #else
      #define DELTA_EPOCH_IN_MICROSECS  11644473600000000ULL
    #endif
     
    struct timezone
    {
        int  tz_minuteswest; /* minutes W of Greenwich */
        int  tz_dsttime;     /* type of dst correction */
    };
    struct timeval {
        long tv_sec;
        long tv_usec;
    };
    
    int __cdecl gettimeofday(
         struct timeval  *tv,
         struct timezone *tz
    )
    {
        FILETIME ft;
        unsigned __int64 tmpres = 0;
        static int tzflag;
    
        if (NULL != tv) {
            GetSystemTimeAsFileTime(&ft);
    
            tmpres |= ft.dwHighDateTime;
            tmpres <<= 32;
            tmpres |= ft.dwLowDateTime;
    
            /*converting file time to unix epoch*/
            tmpres -= DELTA_EPOCH_IN_MICROSECS;
            tmpres /= 10;  /*convert into microseconds*/
            tv->tv_sec = (long)(tmpres / 1000000UL);
            tv->tv_usec = (long)(tmpres % 1000000UL);
        }
    
        if (NULL != tz) {
            int i;
            long l = 0;
            if (!tzflag) {
                _tzset();
                tzflag++;
            }
            _get_timezone(&l);
            tz->tz_minuteswest = l / 60;
            _get_daylight(&i);
            tz->tz_dsttime = i;
        }
    
        return 0;
    }
    
    int __cdecl usleep(
         unsigned int useconds
    )
    {
        if(useconds == 0)
            return 0;
    
        if(useconds >= 1000000)
            return EINVAL;
    
        Sleep((useconds + 999) / 1000);
    
        return 0;
    }
    
    double __cdecl __strtod(
         const char *nptr,
         char **endptr
    )
    {
        return strtod(nptr, endptr);
    }
    
    double __cdecl trunc(
         double n
    )
    {
        return n > 0.0 ? floor(n) : ceil(n);
    }
    
    int __cdecl __mingw_vsscanf(
         const char *s,
         const char *fmt,
         va_list ap
    )
    {
        void *a[5];
        int i;
        for (i=0; i < sizeof(a)/sizeof(a[0]); i++)
            a[i] = va_arg(ap, void *);
        return sscanf(s, fmt, a[0], a[1], a[2], a[3], a[4]);
    }
    
    unsigned __int64 __cdecl udivmodsi4(
         unsigned __int64 num,
         unsigned __int64 den,
         int modwanted
    )
    {
        unsigned __int64 bit = 1;
        unsigned __int64 res = 0;
    
        while (den < num && bit && !(den & (1L<<31))) {
            den <<=1;
            bit <<=1;
        }
        while (bit) {
            if (num >= den) {
                num -= den;
                res |= bit;
            }
            bit >>=1;
            den >>=1;
        }
        return modwanted ? num : res;
    }
    
    __int64 __cdecl __divdi3(
         __int64 a,
         __int64 b
    )
    {
        int neg = 0;
        __int64 res;
    
        if (a < 0) {
            a = -a;
            neg = !neg;
        }
    
        if (b < 0) {
            b = -b;
            neg = !neg;
        }
    
        res = udivmodsi4(a, b, 0);
    
        if (neg)
            res = -res;
    
        return res;
    }
    
    __int64 __cdecl __moddi3(
         __int64 a,
         __int64 b
    )
    {
        int neg = 0;
        __int64 res;
    
        if (a < 0) {
            a = -a;
            neg = 1;
        }
    
        if (b < 0)
            b = -b;
    
        res = udivmodsi4(a, b, 1);
    
        if (neg)
            res = -res;
    
        return res;
    }
    
    unsigned __int64 __cdecl __udivdi3(
         unsigned __int64 a,
         unsigned __int64 b
    )
    {
        return udivmodsi4 (a, b, 0);
    }
    
    unsigned __int64 __cdecl __umoddi3(
         unsigned __int64 a,
         unsigned __int64 b
    )
    {
        return udivmodsi4 (a, b, 1);
    }
    
    
    


    wzplayer 相关链接:

    delphi:支持:http://blog.csdn.net/weinyzhou/article/details/8105126

    ios:http://blog.csdn.net/weinyzhou/article/details/8091688

    android:http://blog.csdn.net/weinyzhou/article/details/7723673


    ffmpeg移植相关

    android mk auto build:http://blog.csdn.net/weinyzhou/article/details/7559205

    ffmpeg vc移植项目,支持ffmpeg 代码VC调试:http://blog.csdn.net/weinyzhou/article/details/7559205

    以上项目,都是付费,需要的用户可以联系.


    版权所有,禁止用于商业用途及转载.

    发布自:http://blog.csdn.net/weinyzhou/article/details/8120005


  • 相关阅读:
    【大厂面试】字节跳动、京东等大厂面试题分享,已拿字节offer~
    听说这十道面试题,把百分之八十的程序员都淘汰了?不是吧,阿sir
    阿里大神的刷题笔记.pdf
    在家学了6个月,拿到阿里offer!
    【面试题】2020年底总结200道带答案的常见Java面试题!
    面试一家小公司,被问了 1 个小时并发编程。。全程已记录!
    分享一份技术书籍《Java 8 》PDF版,可自行下载
    Delphi的TDataSetProvider、TDataSet、TAdoQuery、TDataSource、TDataModule控件的组合使用
    初学Delphi与sql server的存储过程
    delphi简单的分页实现(高手可以不看)
  • 原文地址:https://www.cnblogs.com/weinyzhou/p/2750046.html
Copyright © 2011-2022 走看看