dauddec.c 1.96 KB
Newer Older
1
/*
2
 * D-Cinema audio demuxer
Diego Biurrun's avatar
Diego Biurrun committed
3
 * Copyright (c) 2005 Reimar Döffinger
4
 *
5 6 7
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
8 9
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
13 14 15 16 17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21 22

#include "libavutil/channel_layout.h"
23 24
#include "avformat.h"

25
static int daud_header(AVFormatContext *s) {
26
    AVStream *st = avformat_new_stream(s, NULL);
27 28
    if (!st)
        return AVERROR(ENOMEM);
29 30 31 32 33 34 35 36 37
    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
    st->codecpar->codec_id = AV_CODEC_ID_PCM_S24DAUD;
    st->codecpar->codec_tag = MKTAG('d', 'a', 'u', 'd');
    st->codecpar->channels = 6;
    st->codecpar->channel_layout = AV_CH_LAYOUT_5POINT1;
    st->codecpar->sample_rate = 96000;
    st->codecpar->bit_rate = 3 * 6 * 96000 * 8;
    st->codecpar->block_align = 3 * 6;
    st->codecpar->bits_per_coded_sample = 24;
38 39 40 41
    return 0;
}

static int daud_packet(AVFormatContext *s, AVPacket *pkt) {
42
    AVIOContext *pb = s->pb;
43
    int ret, size;
44
    if (avio_feof(pb))
45
        return AVERROR(EIO);
46 47
    size = avio_rb16(pb);
    avio_rb16(pb); // unknown
48 49 50 51 52
    ret = av_get_packet(pb, pkt, size);
    pkt->stream_index = 0;
    return ret;
}

53
AVInputFormat ff_daud_demuxer = {
54
    .name           = "daud",
55
    .long_name      = NULL_IF_CONFIG_SMALL("D-Cinema audio"),
56 57
    .read_header    = daud_header,
    .read_packet    = daud_packet,
58
    .extensions     = "302,daud",
59
};