On 04/24/2011 12:13 PM, Justin Ruggles wrote:

> On 04/24/2011 04:54 AM, Måns Rullgård wrote:
> 
>> Justin Ruggles <[email protected]> writes:
>>
>>> On 04/23/2011 11:30 AM, Måns Rullgård wrote:
>>>
>>>> Diego Biurrun <[email protected]> writes:
>>>>
>>>>> On Fri, Apr 22, 2011 at 10:19:44PM -0400, Justin Ruggles wrote:
>>>>>>
>>>>>> Based on patches by clsid2 in ffdshow-tryout.
>>>>>>
>>>>>> --- a/configure
>>>>>> +++ b/configure
>>>>>> @@ -95,6 +95,7 @@ Configuration options:
>>>>>>    --disable-mpegaudio-hp   faster (but less accurate) MPEG audio 
>>>>>> decoding [no]
>>>>>> +  --enable-audio-float     floating-point output from some audio 
>>>>>> decoders [no]
>>>>>
>>>>> The comment is not very descriptive.
>>>>
>>>> I really would prefer runtime selection.
>>>
>>> One issue is not a big deal, just annoying.  av_find_stream_info()
>>> doesn't get the AVOptions, and it requires the decoder to always be
>>> opened to get the sample_fmt.  So in this case any requested sample_fmt
>>> will not be known and it will be set to default.  Because the encoders
>>> are opened before the decoders in ffmpeg, the encoder sample_fmt will be
>>> selected based on that default sample_fmt from the decoder.  Then after
>>> the decoder is opened it sets the input sample_fmt to the requested one
>>> this time, but the encoder has already been initialized with the
>>> original default.
>>>
>>> If the user doesn't request a sample_fmt explicitly, we have another
>>> issue.  Either we set the decoder sample_fmt based on the encoder or we
>>> set the encoder sample_fmt based on the decoder.  We could choose the
>>> most accurate supported sample format on one side or the other, then
>>> choose the best option on the other side... but anyway we solve this, it
>>> is a lot of mess for a temporary solution...
>>
>> Sounds like something needs to be fixed then.  Anyway, why this patch at
>> all if it's temporary?  It's quite ugly, and the proper format
>> conversion API is nowhere in sight.
> 
> 
> I'll try today to see if I can get the AVOptions set before
> av_find_stream_info() in ffmpeg.c.  If I can do that, I think the
> request_sample_fmt behavior would at least be acceptable.


I was able to get this working.  So after the change, here is what the
ffmpeg behavior would be when using the request_sample_fmt version of
the patch.

$ ffmpeg -i in.ac3 -acodec pcm_f32le -y out.wav
decoder initialized to s16 during av_find_stream_info()
warning about incompatible sample format
encoder initialized to flt
decoder request_sample_fmt set to flt
decoder initialized to flt
message about the input stream changing format

$ ffmpeg -i in.ac3 -acodec pcm_f64le -y out.wav
decoder initialized to s16 during av_find_stream_info()
warning about incompatible sample format
encoder initialized to dbl
decoder request_sample_fmt set to flt
decoder initialized to flt
message about the input stream changing format
ffmpeg converts from flt to dbl

$ ffmpeg -request_sample_fmt flt -i in.ac3 -acodec pcm_f32le -y out.wav
decoder initialized to flt during av_find_stream_info()
encoder initialized to flt
decoder initialized to flt

$ ffmpeg -request_sample_fmt flt -i in.ac3 -acodec pcm_s16le -y out.wav
decoder initialized to flt during av_find_stream_info()
warning about incompatible sample format
encoder initialized to s16
decoder initialized to flt
ffmpeg converts float to s16

$ ffmpeg -request_sample_fmt s16 -i in.ac3 -acodec pcm_f32le -y out.wav
decoder initialized to s16 during av_find_stream_info()
warning about incompatible sample format
encoder initialized to flt
decoder initialized to s16
ffmpeg converts s16 to flt

Thoughts?

-Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to