[FFmpeg-devel] [PATCH 1/2] osx: detect version of mac os

Xidorn Quan quanxunzhen at gmail.com
Fri Aug 24 12:33:29 CEST 2012


On Fri, Aug 24, 2012 at 5:48 PM, Stefano Sabatini <stefasab at gmail.com>wrote:

> On date Friday 2012-08-24 06:48:36 +0800, Xidorn Quan encoded:
> > On Fri, Aug 24, 2012 at 1:25 AM, Stefano Sabatini <stefasab at gmail.com
> >wrote:
> >
> > >
> > > Also how this belongs to a media library? I mean why this should be
> > > defined in a generic library, rather than, say, in a MacOS
> > > application/library?
> > >
> > > For library implementation purposes we only need to know when a
> > > feature is available or not, and this is done during the configuration
> > > stage.
> >
> >
>
> > So why do you have libavutil/cpu.c belonging to ffmpeg? Why do you
> > need to detect CPU flags on the runtime? Shouldn't it be done during
> > the configuration stage?
>
> CPU flags are not dependent on the OS system. Also there are some
> cases when you want to get fine grained features at run time (e.g. =>
> HAVE_SSE => SSE, SSE2, SSE3 SSSSE3 etc.). I suppose this could be done
> at the configuration stage as well, can't really comment why it is
> done this way).
>
> But the main issue is that if we accept this, we would have to accept
> then av_get_linux_version(), av_get_bsd_version(),
> av_get_windows_version(), av_get_android_version() etc. etc. ad
> nauseam.
>
> A possible solution would be to have an av_get_os_version(), but given
> that it might be hard to get a common scheme (e.g. name, family,
> major, micro, minor) for all OS/kernels then for fixing this case a
> local solution might be more suitable.
>
> ...
>
> Elaborating more on this:
>
>     /* init pix_fmts of codec */
> +    if (!ff_h264_vda_decoder.pix_fmts) {
> +        int major, minor, bugfix;
> +        if (!av_get_osx_version(&major, &minor, &bugfix)) {
> +            av_assert0(major == 10);
> +            av_log(avctx, AV_LOG_VERBOSE, "Detected system version:
> %d.%d.%d\n",
> +                    major, minor, bugfix);
> +            if (minor < 7)
> +                ff_h264_vda_decoder.pix_fmts = vda_pixfmts_prior_10_7;
> +            else
> +                ff_h264_vda_decoder.pix_fmts = vda_pixfmts;
> +        } else {
> +            av_log(avctx, AV_LOG_WARNING,
> +                    "Failed to determine system version.\n");
> +            ff_h264_vda_decoder.pix_fmts = vda_pixfmts;
> +        }
> +    }
>
> Possible solutions I see:
>
> * configuration stage detection, you could use check_code() and define
>   HAVE_MACOSX_VDA_PIXFMTS or whatever
>
> * you add a static function in you implementation:
>
> #if HAVE_MACOSX_FOOBAR
> static int get_osx_version(...)
> {
> ...
> }
> #endif
>
> ...
>
> #if HAVE_MACOSX_FOOBAR
>         if (get_osx_version(&major, &minor, &bugfix)) {
>             av_assert0(major == 10);
>             av_log(avctx, AV_LOG_VERBOSE, "Detected system version:
> %d.%d.%d\n",
> ...
>

Well, I have submitted another patch which doesn't need this function for
the decoder.
I use the method provided by Sebastien.
Just ignore this patch since it is now unnecessary.


More information about the ffmpeg-devel mailing list