* QCP format (.qcp) demuxer
* Copyright (c) 2009 Kenan Gillet
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav 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,
+ * Libav 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
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
- * @file libavformat/qcp.c
+ * @file
* QCP format (.qcp) demuxer
* @author Kenan Gillet
- * @sa RFC 3625: "The QCP File Format and Media Types for Speech Data"
+ * @see RFC 3625: "The QCP File Format and Media Types for Speech Data"
* http://tools.ietf.org/html/rfc3625
*/
static int qcp_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
QCPContext *c = s->priv_data;
- AVStream *st = av_new_stream(s, 0);
+ AVStream *st = avformat_new_stream(s, NULL);
uint8_t buf[16];
int i, nb_rates;
if (!st)
return AVERROR(ENOMEM);
- get_be32(pb); // "RIFF"
- s->file_size = get_le32(pb) + 8;
- url_fskip(pb, 8 + 4 + 1 + 1); // "QLCMfmt " + chunk-size + major-version + minor-version
+ avio_rb32(pb); // "RIFF"
+ avio_skip(pb, 4 + 8 + 4 + 1 + 1); // filesize + "QLCMfmt " + chunk-size + major-version + minor-version
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->channels = 1;
- get_buffer(pb, buf, 16);
+ avio_read(pb, buf, 16);
if (is_qcelp_13k_guid(buf)) {
st->codec->codec_id = CODEC_ID_QCELP;
} else if (!memcmp(buf, guid_evrc, 16)) {
av_log(s, AV_LOG_ERROR, "Unknown codec GUID.\n");
return AVERROR_INVALIDDATA;
}
- url_fskip(pb, 2 + 80); // codec-version + codec-name
- st->codec->bit_rate = get_le16(pb);
+ avio_skip(pb, 2 + 80); // codec-version + codec-name
+ st->codec->bit_rate = avio_rl16(pb);
- s->packet_size = get_le16(pb);
- url_fskip(pb, 2); // block-size
- st->codec->sample_rate = get_le16(pb);
- url_fskip(pb, 2); // sample-size
+ s->packet_size = avio_rl16(pb);
+ avio_skip(pb, 2); // block-size
+ st->codec->sample_rate = avio_rl16(pb);
+ avio_skip(pb, 2); // sample-size
memset(c->rates_per_mode, -1, sizeof(c->rates_per_mode));
- nb_rates = get_le32(pb);
+ nb_rates = avio_rl32(pb);
nb_rates = FFMIN(nb_rates, 8);
for (i=0; i<nb_rates; i++) {
- int size = get_byte(pb);
- int mode = get_byte(pb);
+ int size = avio_r8(pb);
+ int mode = avio_r8(pb);
if (mode > QCP_MAX_MODE) {
av_log(s, AV_LOG_WARNING, "Unknown entry %d=>%d in rate-map-table.\n ", mode, size);
} else
c->rates_per_mode[mode] = size;
}
- url_fskip(pb, 16 - 2*nb_rates + 20); // empty entries of rate-map-table + reserved
+ avio_skip(pb, 16 - 2*nb_rates + 20); // empty entries of rate-map-table + reserved
return 0;
}
static int qcp_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
+ AVIOContext *pb = s->pb;
QCPContext *c = s->priv_data;
unsigned int chunk_size, tag;
- while(!url_feof(pb)) {
+ while(!pb->eof_reached) {
if (c->data_size) {
- int pkt_size, ret, mode = get_byte(pb);
+ int pkt_size, ret, mode = avio_r8(pb);
if (s->packet_size) {
pkt_size = s->packet_size - 1;
return ret;
}
- if (url_ftell(pb) & 1 && get_byte(pb))
+ if (avio_tell(pb) & 1 && avio_r8(pb))
av_log(s, AV_LOG_WARNING, "Padding should be 0.\n");
- tag = get_le32(pb);
- chunk_size = get_le32(pb);
+ tag = avio_rl32(pb);
+ chunk_size = avio_rl32(pb);
switch (tag) {
case MKTAG('v', 'r', 'a', 't'):
- if (get_le32(pb)) // var-rate-flag
+ if (avio_rl32(pb)) // var-rate-flag
s->packet_size = 0;
- url_fskip(pb, 4); // size-in-packets
+ avio_skip(pb, 4); // size-in-packets
break;
case MKTAG('d', 'a', 't', 'a'):
c->data_size = chunk_size;
break;
default:
- url_fskip(pb, chunk_size);
+ avio_skip(pb, chunk_size);
}
}
return AVERROR_EOF;
}
-AVInputFormat qcp_demuxer = {
+AVInputFormat ff_qcp_demuxer = {
.name = "qcp",
.long_name = NULL_IF_CONFIG_SMALL("QCP format"),
.priv_data_size = sizeof(QCPContext),