00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "avformat.h"
00022
00023 static int daud_header(AVFormatContext *s, AVFormatParameters *ap) {
00024 AVStream *st = av_new_stream(s, 0);
00025 if (!st)
00026 return AVERROR(ENOMEM);
00027 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
00028 st->codec->codec_id = CODEC_ID_PCM_S24DAUD;
00029 st->codec->codec_tag = MKTAG('d', 'a', 'u', 'd');
00030 st->codec->channels = 6;
00031 st->codec->sample_rate = 96000;
00032 st->codec->bit_rate = 3 * 6 * 96000 * 8;
00033 st->codec->block_align = 3 * 6;
00034 st->codec->bits_per_coded_sample = 24;
00035 return 0;
00036 }
00037
00038 static int daud_packet(AVFormatContext *s, AVPacket *pkt) {
00039 ByteIOContext *pb = s->pb;
00040 int ret, size;
00041 if (url_feof(pb))
00042 return AVERROR(EIO);
00043 size = get_be16(pb);
00044 get_be16(pb);
00045 ret = av_get_packet(pb, pkt, size);
00046 pkt->stream_index = 0;
00047 return ret;
00048 }
00049
00050 static int daud_write_header(struct AVFormatContext *s)
00051 {
00052 AVCodecContext *codec = s->streams[0]->codec;
00053 if (codec->channels!=6 || codec->sample_rate!=96000)
00054 return -1;
00055 return 0;
00056 }
00057
00058 static int daud_write_packet(struct AVFormatContext *s, AVPacket *pkt)
00059 {
00060 put_be16(s->pb, pkt->size);
00061 put_be16(s->pb, 0x8010);
00062 put_buffer(s->pb, pkt->data, pkt->size);
00063 put_flush_packet(s->pb);
00064 return 0;
00065 }
00066
00067 #if CONFIG_DAUD_DEMUXER
00068 AVInputFormat daud_demuxer = {
00069 "daud",
00070 NULL_IF_CONFIG_SMALL("D-Cinema audio format"),
00071 0,
00072 NULL,
00073 daud_header,
00074 daud_packet,
00075 NULL,
00076 NULL,
00077 .extensions = "302",
00078 };
00079 #endif
00080
00081 #if CONFIG_DAUD_MUXER
00082 AVOutputFormat daud_muxer =
00083 {
00084 "daud",
00085 NULL_IF_CONFIG_SMALL("D-Cinema audio format"),
00086 NULL,
00087 "302",
00088 0,
00089 CODEC_ID_PCM_S24DAUD,
00090 CODEC_ID_NONE,
00091 daud_write_header,
00092 daud_write_packet,
00093 .flags= AVFMT_NOTIMESTAMPS,
00094 };
00095 #endif