• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavformat/daud.c

Go to the documentation of this file.
00001 /*
00002  * D-Cinema audio demuxer
00003  * Copyright (c) 2005 Reimar Döffinger
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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     AVIOContext *pb = s->pb;
00040     int ret, size;
00041     if (url_feof(pb))
00042         return AVERROR(EIO);
00043     size = avio_rb16(pb);
00044     avio_rb16(pb); // unknown
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     if (pkt->size > 65535) {
00061         av_log(s, AV_LOG_ERROR,
00062                "Packet size too large for s302m. (%d > 65535)\n", pkt->size);
00063         return -1;
00064     }
00065     avio_wb16(s->pb, pkt->size);
00066     avio_wb16(s->pb, 0x8010); // unknown
00067     avio_write(s->pb, pkt->data, pkt->size);
00068     avio_flush(s->pb);
00069     return 0;
00070 }
00071 
00072 #if CONFIG_DAUD_DEMUXER
00073 AVInputFormat ff_daud_demuxer = {
00074     "daud",
00075     NULL_IF_CONFIG_SMALL("D-Cinema audio format"),
00076     0,
00077     NULL,
00078     daud_header,
00079     daud_packet,
00080     NULL,
00081     NULL,
00082     .extensions = "302",
00083 };
00084 #endif
00085 
00086 #if CONFIG_DAUD_MUXER
00087 AVOutputFormat ff_daud_muxer =
00088 {
00089     "daud",
00090     NULL_IF_CONFIG_SMALL("D-Cinema audio format"),
00091     NULL,
00092     "302",
00093     0,
00094     CODEC_ID_PCM_S24DAUD,
00095     CODEC_ID_NONE,
00096     daud_write_header,
00097     daud_write_packet,
00098     .flags= AVFMT_NOTIMESTAMPS,
00099 };
00100 #endif

Generated on Fri Feb 22 2013 07:24:31 for FFmpeg by  doxygen 1.7.1