X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fbit.c;h=1249ea1aee353f0cada9dc637e3ec6bf67d6419f;hb=7e09fe15d5d0eb021b6932330e2728fb026df2c0;hp=7400d24fdc987ab16c3d5ac96e29c0eb03fc99a1;hpb=9b471735459d7274f6d7cc646f1d01011f844862;p=ffmpeg diff --git a/libavformat/bit.c b/libavformat/bit.c index 7400d24fdc9..1249ea1aee3 100644 --- a/libavformat/bit.c +++ b/libavformat/bit.c @@ -1,4 +1,25 @@ +/* + * G.729 bit format muxer and demuxer + * Copyright (c) 2007-2008 Vladimir Voroshilov + * + * 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 + */ #include "avformat.h" +#include "internal.h" #include "libavcodec/get_bits.h" #include "libavcodec/put_bits.h" @@ -12,6 +33,9 @@ static int probe(AVProbeData *p) { int i, j; + if(p->buf_size < 0x40) + return 0; + for(i=0; i+3buf_size && i< 10*0x50; ){ if(AV_RL16(&p->buf[0]) != SYNC_WORD) return 0; @@ -27,7 +51,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) { AVStream* st; - st=av_new_stream(s, 0); + st=avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -37,14 +61,14 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->block_align = 16; st->codec->channels=1; - av_set_pts_info(st, 64, 1, 100); + avpriv_set_pts_info(st, 64, 1, 100); return 0; } static int read_packet(AVFormatContext *s, AVPacket *pkt) { - ByteIOContext *pb = s->pb; + AVIOContext *pb = s->pb; PutBitContext pbo; uint16_t buf[8 * MAX_FRAME_SIZE + 2]; int packet_size; @@ -55,12 +79,12 @@ static int read_packet(AVFormatContext *s, if(url_feof(pb)) return AVERROR_EOF; - get_le16(pb); // sync word - packet_size = get_le16(pb) / 8; + avio_rl16(pb); // sync word + packet_size = avio_rl16(pb) / 8; if(packet_size > MAX_FRAME_SIZE) return AVERROR_INVALIDDATA; - ret = get_buffer(pb, (uint8_t*)buf, (8 * packet_size) * sizeof(uint16_t)); + ret = avio_read(pb, (uint8_t*)buf, (8 * packet_size) * sizeof(uint16_t)); if(ret<0) return ret; if(ret != 8 * packet_size * sizeof(uint16_t)) @@ -89,7 +113,7 @@ AVInputFormat ff_bit_demuxer = { .extensions = "bit", }; -#ifdef CONFIG_MUXERS +#if CONFIG_MUXERS static int write_header(AVFormatContext *s) { AVCodecContext *enc = s->streams[0]->codec; @@ -104,17 +128,17 @@ static int write_header(AVFormatContext *s) static int write_packet(AVFormatContext *s, AVPacket *pkt) { - ByteIOContext *pb = s->pb; + AVIOContext *pb = s->pb; GetBitContext gb; int i; - put_le16(pb, SYNC_WORD); - put_le16(pb, 8 * 10); + avio_wl16(pb, SYNC_WORD); + avio_wl16(pb, 8 * 10); init_get_bits(&gb, pkt->data, 8*10); for(i=0; i< 8 * 10; i++) - put_le16(pb, get_bits1(&gb) ? BIT_1 : BIT_0); - put_flush_packet(pb); + avio_wl16(pb, get_bits1(&gb) ? BIT_1 : BIT_0); + avio_flush(pb); return 0; }