* IEC 61937 demuxer
* Copyright (c) 2010 Anssi Hannula <anssi.hannula at iki.fi>
*
- * 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
*/
#include "libavcodec/aacadtsdec.h"
static int spdif_get_offset_and_codec(AVFormatContext *s,
- enum IEC958DataType data_type,
+ enum IEC61937DataType data_type,
const char *buf, int *offset,
enum CodecID *codec)
{
GetBitContext gbc;
switch (data_type & 0xff) {
- case IEC958_AC3:
+ case IEC61937_AC3:
*offset = AC3_FRAME_SIZE << 2;
*codec = CODEC_ID_AC3;
break;
- case IEC958_MPEG1_LAYER1:
+ case IEC61937_MPEG1_LAYER1:
*offset = spdif_mpeg_pkt_offset[1][0];
*codec = CODEC_ID_MP1;
break;
- case IEC958_MPEG1_LAYER23:
+ case IEC61937_MPEG1_LAYER23:
*offset = spdif_mpeg_pkt_offset[1][0];
*codec = CODEC_ID_MP3;
break;
- case IEC958_MPEG2_EXT:
+ case IEC61937_MPEG2_EXT:
*offset = 4608;
*codec = CODEC_ID_MP3;
break;
- case IEC958_MPEG2_AAC:
+ case IEC61937_MPEG2_AAC:
init_get_bits(&gbc, buf, AAC_ADTS_HEADER_SIZE * 8);
if (ff_aac_parse_header(&gbc, &aac_hdr)) {
if (s) /* be silent during a probe */
*offset = aac_hdr.samples << 2;
*codec = CODEC_ID_AAC;
break;
- case IEC958_MPEG2_LAYER1_LSF:
+ case IEC61937_MPEG2_LAYER1_LSF:
*offset = spdif_mpeg_pkt_offset[0][0];
*codec = CODEC_ID_MP1;
break;
- case IEC958_MPEG2_LAYER2_LSF:
+ case IEC61937_MPEG2_LAYER2_LSF:
*offset = spdif_mpeg_pkt_offset[0][1];
*codec = CODEC_ID_MP2;
break;
- case IEC958_MPEG2_LAYER3_LSF:
+ case IEC61937_MPEG2_LAYER3_LSF:
*offset = spdif_mpeg_pkt_offset[0][2];
*codec = CODEC_ID_MP3;
break;
- case IEC958_DTS1:
+ case IEC61937_DTS1:
*offset = 2048;
*codec = CODEC_ID_DTS;
break;
- case IEC958_DTS2:
+ case IEC61937_DTS2:
*offset = 4096;
*codec = CODEC_ID_DTS;
break;
- case IEC958_DTS3:
+ case IEC61937_DTS3:
*offset = 8192;
*codec = CODEC_ID_DTS;
break;
static int spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- ByteIOContext *pb = s->pb;
- enum IEC958DataType data_type;
+ AVIOContext *pb = s->pb;
+ enum IEC61937DataType data_type;
enum CodecID codec_id;
uint32_t state = 0;
int pkt_size_bits, offset, ret;
while (state != (AV_BSWAP16C(SYNCWORD1) << 16 | AV_BSWAP16C(SYNCWORD2))) {
- state = (state << 8) | get_byte(pb);
- if (url_feof(pb))
+ state = (state << 8) | avio_r8(pb);
+ if (pb->eof_reached)
return AVERROR_EOF;
}
- data_type = get_le16(pb);
- pkt_size_bits = get_le16(pb);
+ data_type = avio_rl16(pb);
+ pkt_size_bits = avio_rl16(pb);
if (pkt_size_bits % 16)
av_log_ask_for_sample(s, "Packet does not end to a 16-bit boundary.");
if (ret)
return ret;
- pkt->pos = url_ftell(pb) - BURST_HEADER_SIZE;
+ pkt->pos = avio_tell(pb) - BURST_HEADER_SIZE;
- if (get_buffer(pb, pkt->data, pkt->size) < pkt->size) {
+ if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {
av_free_packet(pkt);
return AVERROR_EOF;
}
}
/* skip over the padding to the beginning of the next frame */
- url_fskip(pb, offset - pkt->size - BURST_HEADER_SIZE);
+ avio_skip(pb, offset - pkt->size - BURST_HEADER_SIZE);
if (!s->nb_streams) {
/* first packet, create a stream */
return 0;
}
-AVInputFormat spdif_demuxer = {
+AVInputFormat ff_spdif_demuxer = {
"spdif",
NULL_IF_CONFIG_SMALL("IEC 61937 (compressed data in S/PDIF)"),
0,