diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-10-26 16:07:04 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-26 16:24:57 +0400 |
commit | 507f2940ccdcedf2fdc064c5fb6022b60bace8ca (patch) | |
tree | a367ef88e7671ef3155d52bf0f8137fc1c2b0339 /libavformat/pcmdec.c | |
parent | 9f36ec6aa936515a703f6d7ff32826aa28684f1e (diff) | |
parent | 1b891d17c531e8a63c2974aab4bf997ce70746f3 (diff) |
Merge commit '1b891d17c531e8a63c2974aab4bf997ce70746f3'
* commit '1b891d17c531e8a63c2974aab4bf997ce70746f3':
avconv: fix bitrate report when writing to /dev/null
avfilter: fix graphparser memleaks on error paths
rawdec: remove ff_raw_read_header
pcmdec: remove dependency from rawdec
g722: refactor out of rawdec.c
rawvideo: use a specific read_header
Conflicts:
ffmpeg.c
libavformat/Makefile
libavformat/rawdec.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/pcmdec.c')
-rw-r--r-- | libavformat/pcmdec.c | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c index 178c251f14..5ed572b8f7 100644 --- a/libavformat/pcmdec.c +++ b/libavformat/pcmdec.c @@ -20,7 +20,7 @@ */ #include "avformat.h" -#include "rawdec.h" +#include "internal.h" #include "pcm.h" #include "libavutil/log.h" #include "libavutil/opt.h" @@ -28,6 +28,39 @@ #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); + + av_assert0(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; @@ -51,8 +84,8 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) } static const AVOption pcm_options[] = { - { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, - { "channels", "", offsetof(RawAudioDemuxerContext, channels), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 44100}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "channels", "", offsetof(RawAudioDemuxerContext, channels), AV_OPT_TYPE_INT, {.i64 = 1}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; @@ -67,7 +100,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, \ |