[FFmpeg-devel] [PATCH 2/2] lavd/lavfi: support all sample formats.
Stefano Sabatini
stefasab at gmail.com
Tue Feb 21 11:05:28 CET 2012
On Thu, Feb 16, 2012 at 3:01 PM, Nicolas George
<nicolas.george at normalesup.org> wrote:
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> libavdevice/lavfi.c | 8 ++++++--
> 1 files changed, 6 insertions(+), 2 deletions(-)
>
>
> Stefano: did your code work on big-endian systems?
I confess I never did, I was waiting for big-endian people to complain
and provide a patch ;-).
> diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
> index 30c08e0..19c38d8 100644
> --- a/libavdevice/lavfi.c
> +++ b/libavdevice/lavfi.c
> @@ -206,7 +206,11 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
> if (ret < 0)
> goto end;
> } else if (type == AVMEDIA_TYPE_AUDIO) {
> - enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 };
> + enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_U8,
> + AV_SAMPLE_FMT_S16,
> + AV_SAMPLE_FMT_S32,
> + AV_SAMPLE_FMT_FLT,
> + AV_SAMPLE_FMT_DBL, -1 };
> const int packing_fmts[] = { AVFILTER_PACKED, -1 };
> const int64_t *chlayouts = avfilter_all_channel_layouts;
> AVABufferSinkParams *abuffersink_params = av_abuffersink_params_alloc();
> @@ -253,7 +257,7 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
> st ->sample_aspect_ratio =
> st->codec->sample_aspect_ratio = link->sample_aspect_ratio;
> } else if (link->type == AVMEDIA_TYPE_AUDIO) {
> - st->codec->codec_id = CODEC_ID_PCM_S16LE;
> + st->codec->codec_id = av_get_pcm_codec(link->format, -1);
What happens if codec is set to NONE?, should never happen but an
assert / error message may be useful for debugging/documentation
purposes.
> st->codec->channels = av_get_channel_layout_nb_channels(link->channel_layout);
> st->codec->sample_fmt = link->format;
> st->codec->sample_rate = link->sample_rate;
Looks fine, thanks and sorry for the slow reply.
More information about the ffmpeg-devel
mailing list