[FFmpeg-devel] [PATCH] Default to using libraries when enabled

Baptiste Coudurier baptiste.coudurier
Mon May 24 00:04:01 CEST 2010


On 5/23/10 2:59 PM, Janne Grunau wrote:
> On Sun, May 23, 2010 at 06:41:35PM +0200, Michael Niedermayer wrote:
>> On Sat, May 22, 2010 at 12:48:02PM +0200, Janne Grunau wrote:
>>> See attached patches for selections by codec id. Beside the aac and vorbis
>>> encoder are there other codecs which should be considered experimental?
>>> It's more tricky for selections by codec name since the names are unique.
>>> The best solution is probably to fail in ffmpeg if the encoder is experimental
>>> and -strict (or something else) is not set.
>>
>>>   avcodec.h |    4 ++++
>>>   utils.c   |   24 ++++++++++++++++--------
>>>   2 files changed, 20 insertions(+), 8 deletions(-)
>>> 62657abb5bcdd4c0791216099c04dc0e3b6cde36  avoid_experimental_codecs.diff
>>> commit 75273f4917cf21fcab6da91c048fae5955012b68
>>> Author: Janne Grunau<janne at grunau.be>
>>> Date:   Sat May 22 02:19:30 2010 +0200
>>>
>>>      add CODEC_CAP_EXPERIMENTAL and prefer codecs without this capability
>>>
>>>      avcodec_find_{de|en}coder returns only imidiately if CODEC_CAP_EXPERIMENTAL
>>>      is not set. The first experimental codec is saved and returned if no other
>>>      codec was found.
>>>
>>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>>> index 8781c0a..a0d6498 100644
>>> --- a/libavcodec/avcodec.h
>>> +++ b/libavcodec/avcodec.h
>>> @@ -645,6 +645,10 @@ typedef struct RcOverride{
>>>    * as a last resort.
>>>    */
>>>   #define CODEC_CAP_SUBFRAMES        0x0100
>>> +/**
>>> + * Codec is experimental
>>
>> // and is thus avoided in favor of non experimental encoders
>
> updated patch attached
>
>> the rest of the patch is ok with me
>
> Janne
>
>
> avoid_experimental_codecs2.diff
>
>
> commit 35cda412179490370d56223c5bbd5dd29b35a9f6
> Author: Janne Grunau<janne at grunau.be>
> Date:   Sat May 22 02:19:30 2010 +0200
>
>      add CODEC_CAP_EXPERIMENTAL and prefer codecs without this capability
>
>      avcodec_find_{de|en}coder returns only imidiately if CODEC_CAP_EXPERIMENTAL
>      is not set. The first experimental codec is saved and returned if no other
>      codec was found.
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index cd642ac..5e54953 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -645,6 +645,11 @@ typedef struct RcOverride{
>    * as a last resort.
>    */
>   #define CODEC_CAP_SUBFRAMES        0x0100
> +/**
> + * Codec is experimental and is thus avoided in favor of non experimental
> + * encoders
> + */
> +#define CODEC_CAP_EXPERIMENTAL     0x0200
>
>   //The following defines may change, don't expect compatibility if you use them.
>   #define MB_TYPE_INTRA4x4   0x0001
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 56d4dbd..978e4d3 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -725,14 +725,18 @@ av_cold int avcodec_close(AVCodecContext *avctx)
>
>   AVCodec *avcodec_find_encoder(enum CodecID id)
>   {
> -    AVCodec *p;
> +    AVCodec *p, *experimental=NULL;
>       p = first_avcodec;
>       while (p) {
> -        if (p->encode != NULL&&  p->id == id)
> -            return p;
> +        if (p->encode != NULL&&  p->id == id) {
> +            if (p->capabilities&  CODEC_CAP_EXPERIMENTAL&&  !experimental)
> +                experimental = p;
> +            else
> +                return p;
> +        }
>           p = p->next;
>       }
> -    return NULL;
> +    return experimental;
>   }
>
>   AVCodec *avcodec_find_encoder_by_name(const char *name)
> @@ -751,14 +755,18 @@ AVCodec *avcodec_find_encoder_by_name(const char *name)
>
>   AVCodec *avcodec_find_decoder(enum CodecID id)
>   {
> -    AVCodec *p;
> +    AVCodec *p, *experimental=NULL;
>       p = first_avcodec;
>       while (p) {
> -        if (p->decode != NULL&&  p->id == id)
> -            return p;
> +        if (p->decode != NULL&&  p->id == id) {
> +            if (p->capabilities&  CODEC_CAP_EXPERIMENTAL&&  !experimental)
> +                experimental = p;
> +            else
> +                return p;
> +        }
>           p = p->next;
>       }
> -    return NULL;
> +    return experimental;
>   }
>
>   AVCodec *avcodec_find_decoder_by_name(const char *name)
>

Humm won't this have side effects for decoder developpers ?

Manually selecting encoders is easy, but not decoders.

For encoders I think I'm ok.

-- 
Baptiste COUDURIER
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list