diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2012-10-24 19:15:50 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2012-10-25 14:05:13 +0200 |
commit | 2ef4d586d6352a69c0669d53ce1035eb7d8db0e8 (patch) | |
tree | ae2d503912e1b7ba7a55b51b66b3118337616bfe /libavformat/pcmdec.c | |
parent | 5f0e161dd61552ad70760bad35b869eaec7368ff (diff) | |
download | ffmpeg-2ef4d586d6352a69c0669d53ce1035eb7d8db0e8.tar.gz |
pcmdec: remove dependency from rawdec
The code shared is not actually shared with anything else.
Diffstat (limited to 'libavformat/pcmdec.c')
-rw-r--r-- | libavformat/pcmdec.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c index ad47885297..40446c29e3 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) +{ + 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, \ |