00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <string.h>
00023 #include "avformat.h"
00024
00025 static int apc_probe(AVProbeData *p)
00026 {
00027 if (!strncmp(p->buf, "CRYO_APC", 8))
00028 return AVPROBE_SCORE_MAX;
00029
00030 return 0;
00031 }
00032
00033 static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap)
00034 {
00035 ByteIOContext *pb = s->pb;
00036 AVStream *st;
00037
00038 get_le32(pb);
00039 get_le32(pb);
00040 get_le32(pb);
00041
00042 st = av_new_stream(s, 0);
00043 if (!st)
00044 return AVERROR(ENOMEM);
00045
00046 st->codec->codec_type = CODEC_TYPE_AUDIO;
00047 st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS;
00048
00049 get_le32(pb);
00050 st->codec->sample_rate = get_le32(pb);
00051
00052 st->codec->extradata_size = 2 * 4;
00053 st->codec->extradata = av_malloc(st->codec->extradata_size +
00054 FF_INPUT_BUFFER_PADDING_SIZE);
00055 if (!st->codec->extradata)
00056 return AVERROR(ENOMEM);
00057
00058
00059 get_buffer(pb, st->codec->extradata, 2 * 4);
00060
00061 st->codec->channels = 1;
00062 if (get_le32(pb))
00063 st->codec->channels = 2;
00064
00065 st->codec->bits_per_coded_sample = 4;
00066 st->codec->bit_rate = st->codec->bits_per_coded_sample * st->codec->channels
00067 * st->codec->sample_rate;
00068 st->codec->block_align = 1;
00069
00070 return 0;
00071 }
00072
00073 #define MAX_READ_SIZE 4096
00074
00075 static int apc_read_packet(AVFormatContext *s, AVPacket *pkt)
00076 {
00077 if (av_get_packet(s->pb, pkt, MAX_READ_SIZE) <= 0)
00078 return AVERROR(EIO);
00079 pkt->stream_index = 0;
00080 return 0;
00081 }
00082
00083 AVInputFormat apc_demuxer = {
00084 "apc",
00085 NULL_IF_CONFIG_SMALL("CRYO APC format"),
00086 0,
00087 apc_probe,
00088 apc_read_header,
00089 apc_read_packet,
00090 };