[FFmpeg-devel] [PATCH 1/2] Add request_sample_fmt field to AVCodecContext to allow user to request a specific sample format from the audio decoder.

Justin Ruggles justin.ruggles
Thu Mar 10 18:46:41 CET 2011


On 03/10/2011 12:13 PM, M?ns Rullg?rd wrote:

> Justin Ruggles <justin.ruggles at gmail.com> writes:
> 
>> On 03/10/2011 11:45 AM, M?ns Rullg?rd wrote:
>>
>>> M?ns Rullg?rd <mans at mansr.com> writes:
>>>
>>>> Justin Ruggles <justin.ruggles at gmail.com> writes:
>>>>
>>>>> @@ -2900,6 +2900,14 @@ typedef struct AVCodecContext {
>>>>>       * - decoding: unused.
>>>>>       */
>>>>>      uint64_t vbv_delay;
>>>>> +
>>>>> +    /**
>>>>> +     * Request decoder to use this sample format if it can (AV_SAMPLE_FMT_NONE
>>>>> +     * for default).
>>>>> +     * - encoding: unused.
>>>>> +     * - decoding: Set by user.
>>>>> +     */
>>>>> +    enum AVSampleFormat request_sample_fmt;
>>>>>  } AVCodecContext;
>>>>>
>>>>>  /**
>>>>> diff --git a/libavcodec/options.c b/libavcodec/options.c
>>>>> index e4bc8a6..e0a4428 100644
>>>>> --- a/libavcodec/options.c
>>>>> +++ b/libavcodec/options.c
>>>>> @@ -436,6 +436,7 @@ static const AVOption options[]={
>>>>>  {"slice", NULL, 0, FF_OPT_TYPE_CONST, FF_THREAD_SLICE, INT_MIN, INT_MAX, V|E|D, "thread_type"},
>>>>>  {"frame", NULL, 0, FF_OPT_TYPE_CONST, FF_THREAD_FRAME, INT_MIN, INT_MAX, V|E|D, "thread_type"},
>>>>>  {"vbv_delay", "initial buffer fill time in periods of 27Mhz clock", 0, FF_OPT_TYPE_INT64, 0, 0, INT64_MAX},
>>>>> +{"request_sample_fmt", NULL, OFFSET(request_sample_fmt), FF_OPT_TYPE_INT, AV_SAMPLE_FMT_NONE, AV_SAMPLE_FMT_NONE, AV_SAMPLE_FMT_NB-1, A|D},
>>>>>  {NULL},
>>>>>  };
>>>>
>>>> Can this be used from the ffmpeg command line somehow?
>>
>> yes.  ffmpeg -request_sample_fmt float -i input_file ...
> 
> By which magic does it recognise symbolic format names?

Good question. It seems it is purely magic (or luck if you prefer). A
list of sample format strings probably needs to be added.

>>> Or at least have ffmpeg.c request whatever input format the encoder
>>> wants?
>>
>> maybe possible. I'll look into it.
> 
> Great.  If we're adding this feature, we should make the best use of it.




More information about the ffmpeg-devel mailing list