e8723e24 |
/*
* RSO demuxer
* Copyright (c) 2001 Fabrice Bellard (original AU code)
* Copyright (c) 2010 Rafael Carre
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* 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
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
|
ce842029 |
#include "libavutil/channel_layout.h" |
e8723e24 |
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "internal.h" |
e94204df |
#include "pcm.h" |
e8723e24 |
#include "rso.h"
|
6e9651d1 |
static int rso_read_header(AVFormatContext *s) |
e8723e24 |
{ |
471fe57e |
AVIOContext *pb = s->pb; |
e8723e24 |
int id, rate, bps;
unsigned int size; |
36ef5369 |
enum AVCodecID codec; |
e8723e24 |
AVStream *st;
|
e63a3628 |
id = avio_rb16(pb);
size = avio_rb16(pb);
rate = avio_rb16(pb);
avio_rb16(pb); /* play mode ? (0x0000 = don't loop) */ |
e8723e24 |
codec = ff_codec_get_id(ff_codec_rso_tags, id);
|
36ef5369 |
if (codec == AV_CODEC_ID_ADPCM_IMA_WAV) { |
1ae07959 |
avpriv_report_missing_feature(s, "ADPCM in RSO"); |
e8723e24 |
return AVERROR_PATCHWELCOME;
}
bps = av_get_bits_per_sample(codec);
if (!bps) { |
1ecdf891 |
avpriv_request_sample(s, "Unknown bits per sample"); |
f3298f12 |
return AVERROR_PATCHWELCOME; |
e8723e24 |
}
/* now we are ready: build format streams */ |
3b3bbdd3 |
st = avformat_new_stream(s, NULL); |
e8723e24 |
if (!st)
return AVERROR(ENOMEM);
st->duration = (size * 8) / bps;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = id;
st->codec->codec_id = codec;
st->codec->channels = 1; |
ce842029 |
st->codec->channel_layout = AV_CH_LAYOUT_MONO; |
e8723e24 |
st->codec->sample_rate = rate; |
8ecf22ff |
st->codec->block_align = 1; |
e8723e24 |
|
c3f9ebf7 |
avpriv_set_pts_info(st, 64, 1, rate); |
e8723e24 |
return 0;
}
|
66355be3 |
AVInputFormat ff_rso_demuxer = { |
e8723e24 |
.name = "rso", |
6774247a |
.long_name = NULL_IF_CONFIG_SMALL("Lego Mindstorms RSO"), |
e8723e24 |
.extensions = "rso",
.read_header = rso_read_header, |
8ecf22ff |
.read_packet = ff_pcm_read_packet, |
167f3b8d |
.read_seek = ff_pcm_read_seek, |
e8723e24 |
.codec_tag = (const AVCodecTag* const []){ff_codec_rso_tags, 0},
}; |