[FFmpeg-devel] [PATCH 3/3] lavd/alsa_audio_enc: implementation of query_codec

Lukasz M lukasz.m.luki at gmail.com
Sat Nov 2 12:14:03 CET 2013


On 2 November 2013 10:53, Reimar Döffinger <Reimar.Doeffinger at gmx.de> wrote:

> On Fri, Nov 01, 2013 at 03:40:50PM +0100, Lukasz Marek wrote:
> > Implementation of query_codec callback that allow to
> > check if specific codec is supported by device.
> >
> > Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
> > ---
> >  libavdevice/alsa-audio-enc.c |   25 +++++++++++++++++++++++++
> >  1 file changed, 25 insertions(+)
> >
> > diff --git a/libavdevice/alsa-audio-enc.c b/libavdevice/alsa-audio-enc.c
> > index 0f4e4a2..d3447a3 100644
> > --- a/libavdevice/alsa-audio-enc.c
> > +++ b/libavdevice/alsa-audio-enc.c
> > @@ -115,6 +115,30 @@ audio_get_output_timestamp(AVFormatContext *s1, int
> stream,
> >      *dts = s1->streams[0]->cur_dts - delay;
> >  }
> >
> > +static int audio_query_codec(enum AVCodecID id, int std_compliance)
> > +{
> > +    return id == AV_CODEC_ID_PCM_F64LE ||
> > +           id == AV_CODEC_ID_PCM_F64BE ||
> > +           id == AV_CODEC_ID_PCM_F32LE ||
> > +           id == AV_CODEC_ID_PCM_F32BE ||
> > +           id == AV_CODEC_ID_PCM_S32LE ||
> > +           id == AV_CODEC_ID_PCM_S32BE ||
> > +           id == AV_CODEC_ID_PCM_U32LE ||
> > +           id == AV_CODEC_ID_PCM_U32BE ||
> > +           id == AV_CODEC_ID_PCM_S24LE ||
> > +           id == AV_CODEC_ID_PCM_S24BE ||
> > +           id == AV_CODEC_ID_PCM_U24LE ||
> > +           id == AV_CODEC_ID_PCM_U24BE ||
> > +           id == AV_CODEC_ID_PCM_S16LE ||
> > +           id == AV_CODEC_ID_PCM_S16BE ||
> > +           id == AV_CODEC_ID_PCM_U16LE ||
> > +           id == AV_CODEC_ID_PCM_U16BE ||
> > +           id == AV_CODEC_ID_PCM_S8    ||
> > +           id == AV_CODEC_ID_PCM_U8    ||
> > +           id == AV_CODEC_ID_PCM_MULAW ||
> > +           id == AV_CODEC_ID_PCM_ALAW ? 1: 0;
>
> I'm not sure what the point of it is.
> It doesn't cover all possibilities (e.g. AC3, DTS etc. in SPDIF is often
> supported), while it also contains formats that are
> almost never supported (especially the reverse endianness
> formats, but most of the time only AV_CODEC_ID_PCM_S16LE
> actually works).
> I don't understand what the point of a query function is anyway
> when it doesn't even have enough information to open the device
> and check what actually works...
>

Functionality like this is required when you want to utilize devices in
some apps that is not just ./ffmpeg -i INPUT -f xxx OUTPUT.
Especially when you want to avoid not required format conversions when
possible and not hardcode device -> codec/format mappings.

I see your point. Regarding AC3, DTS, it is not supported by this
implementation yet. So it is not included.
I did some test for LE/BE and both works on my hardware, but I assume it is
not general rule. But in fact some are not (AV_CODEC_ID_PCM_F64*)
Anyway, the important thing you pointed is that not all possibly supported
configurations are really supported by hardware.

It would then require to extend API by more advanced query function. I'm
just not sure query function should return:

1. All possible working configurations (matrix of: hardware device ,
sampling rate, codec, format)

2. All possible working configuration for certain stream and device
 (matrix of: codec, format)

I thing second option is much better as user will send just one stream to
certain device at a time.

Patch dropped in this version anyway.


More information about the ffmpeg-devel mailing list