00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "avformat.h"
00023 #include "rawdec.h"
00024 #include "pcm.h"
00025
00026 #define RAW_SAMPLES 1024
00027
00028 static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
00029 {
00030 int ret, size, bps;
00031
00032
00033 size= RAW_SAMPLES*s->streams[0]->codec->block_align;
00034
00035 ret= av_get_packet(s->pb, pkt, size);
00036
00037 pkt->stream_index = 0;
00038 if (ret < 0)
00039 return ret;
00040
00041 bps= av_get_bits_per_sample(s->streams[0]->codec->codec_id);
00042 assert(bps);
00043 pkt->dts=
00044 pkt->pts= pkt->pos*8 / (bps * s->streams[0]->codec->channels);
00045
00046 return ret;
00047 }
00048
00049 #define PCMDEF(name, long_name, ext, codec) \
00050 AVInputFormat ff_pcm_ ## name ## _demuxer = {\
00051 #name,\
00052 NULL_IF_CONFIG_SMALL(long_name),\
00053 sizeof(RawAudioDemuxerContext),\
00054 NULL,\
00055 ff_raw_read_header,\
00056 raw_read_packet,\
00057 NULL,\
00058 pcm_read_seek,\
00059 .flags= AVFMT_GENERIC_INDEX,\
00060 .extensions = ext,\
00061 .value = codec,\
00062 .priv_class = &ff_rawaudio_demuxer_class,\
00063 };
00064
00065 PCMDEF(f64be, "PCM 64 bit floating-point big-endian format",
00066 NULL, CODEC_ID_PCM_F64BE)
00067
00068 PCMDEF(f64le, "PCM 64 bit floating-point little-endian format",
00069 NULL, CODEC_ID_PCM_F64LE)
00070
00071 PCMDEF(f32be, "PCM 32 bit floating-point big-endian format",
00072 NULL, CODEC_ID_PCM_F32BE)
00073
00074 PCMDEF(f32le, "PCM 32 bit floating-point little-endian format",
00075 NULL, CODEC_ID_PCM_F32LE)
00076
00077 PCMDEF(s32be, "PCM signed 32 bit big-endian format",
00078 NULL, CODEC_ID_PCM_S32BE)
00079
00080 PCMDEF(s32le, "PCM signed 32 bit little-endian format",
00081 NULL, CODEC_ID_PCM_S32LE)
00082
00083 PCMDEF(s24be, "PCM signed 24 bit big-endian format",
00084 NULL, CODEC_ID_PCM_S24BE)
00085
00086 PCMDEF(s24le, "PCM signed 24 bit little-endian format",
00087 NULL, CODEC_ID_PCM_S24LE)
00088
00089 PCMDEF(s16be, "PCM signed 16 bit big-endian format",
00090 AV_NE("sw", NULL), CODEC_ID_PCM_S16BE)
00091
00092 PCMDEF(s16le, "PCM signed 16 bit little-endian format",
00093 AV_NE(NULL, "sw"), CODEC_ID_PCM_S16LE)
00094
00095 PCMDEF(s8, "PCM signed 8 bit format",
00096 "sb", CODEC_ID_PCM_S8)
00097
00098 PCMDEF(u32be, "PCM unsigned 32 bit big-endian format",
00099 NULL, CODEC_ID_PCM_U32BE)
00100
00101 PCMDEF(u32le, "PCM unsigned 32 bit little-endian format",
00102 NULL, CODEC_ID_PCM_U32LE)
00103
00104 PCMDEF(u24be, "PCM unsigned 24 bit big-endian format",
00105 NULL, CODEC_ID_PCM_U24BE)
00106
00107 PCMDEF(u24le, "PCM unsigned 24 bit little-endian format",
00108 NULL, CODEC_ID_PCM_U24LE)
00109
00110 PCMDEF(u16be, "PCM unsigned 16 bit big-endian format",
00111 AV_NE("uw", NULL), CODEC_ID_PCM_U16BE)
00112
00113 PCMDEF(u16le, "PCM unsigned 16 bit little-endian format",
00114 AV_NE(NULL, "uw"), CODEC_ID_PCM_U16LE)
00115
00116 PCMDEF(u8, "PCM unsigned 8 bit format",
00117 "ub", CODEC_ID_PCM_U8)
00118
00119 PCMDEF(alaw, "PCM A-law format",
00120 "al", CODEC_ID_PCM_ALAW)
00121
00122 PCMDEF(mulaw, "PCM mu-law format",
00123 "ul", CODEC_ID_PCM_MULAW)