On 2012-10-24 21:19:42 +0200, Luca Barbato wrote:
> The code shared is not actually shared with anything else.
> ---
>  libavformat/Makefile | 40 ++++++++++++++++++++--------------------
>  libavformat/pcmdec.c | 37 +++++++++++++++++++++++++++++++++++--
>  2 files changed, 55 insertions(+), 22 deletions(-)
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 832ea41..acf0500 100644
> --- a/libavformat/pcmdec.c
> +++ b/libavformat/pcmdec.c
> @@ -20,13 +20,46 @@
>   */
>  
>  #include "avformat.h"
> -#include "rawdec.h"
> +#include "internal.h"
>  #include "pcm.h"
>  #include "libavutil/log.h"
>  #include "libavutil/opt.h"
>  
>  #define RAW_SAMPLES     1024
>  
> +typedef struct RawAudioDemuxerContext {
> +    AVClass *class;
> +    int sample_rate;
> +    int channels;
> +} RawAudioDemuxerContext;
> +
> +static int raw_read_header(AVFormatContext *s)

bikeshed: pcm might be a better prefix for the function and context

> +{
> +    RawAudioDemuxerContext *s1 = s->priv_data;
> +    AVStream *st;
> +
> +    st = avformat_new_stream(s, NULL);
> +    if (!st)
> +        return AVERROR(ENOMEM);
> +
> +
> +    st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
> +    st->codec->codec_id    = s->iformat->raw_codec_id;
> +    st->codec->sample_rate = s1->sample_rate;
> +    st->codec->channels    = s1->channels;
> +
> +    st->codec->bits_per_coded_sample =
> +        av_get_bits_per_sample(st->codec->codec_id);
> +
> +    assert(st->codec->bits_per_coded_sample > 0);
> +
> +    st->codec->block_align =
> +        st->codec->bits_per_coded_sample * st->codec->channels / 8;
> +
> +    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
> +    return 0;
> +}
> +
>  static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
>  {
>      int ret, size, bps;
> @@ -65,7 +98,7 @@ AVInputFormat ff_pcm_ ## name_ ## _demuxer = {              
> \
>      .name           = #name_,                               \
>      .long_name      = NULL_IF_CONFIG_SMALL(long_name_),     \
>      .priv_data_size = sizeof(RawAudioDemuxerContext),       \
> -    .read_header    = ff_raw_read_header,                   \
> +    .read_header    = raw_read_header,                      \
>      .read_packet    = raw_read_packet,                      \
>      .read_seek      = ff_pcm_read_seek,                     \
>      .flags          = AVFMT_GENERIC_INDEX,                  \

ok

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

Reply via email to