1 /*
2 * G.729 bit format muxer and demuxer
3 * Copyright (c) 2007-2008 Vladimir Voroshilov
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * 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 */
25
26 #define MAX_FRAME_SIZE 10
27
28 #define SYNC_WORD 0x6b21
31
33 {
34 int i, j;
35
37 return 0;
38
39 for(i=0; i+3<p->
buf_size && i< 10*0x50; ){
41 return 0;
43 if(j!=0x40 && j!=0x50)
44 return 0;
45 i+=j;
46 }
48 }
49
51 {
53
55 if (!st)
57
63
65 return 0;
66 }
67
70 {
74 int packet_size;
76 int i, j, ret;
78
81
86
88 if(ret<0)
89 return ret;
90 if(ret != 8 * packet_size * sizeof(uint16_t))
92
95
97 for(j=0; j < packet_size; j++)
98 for(i=0; i<8;i++)
100
102
105 return 0;
106 }
107
114 .extensions = "bit",
115 };
116
117 #if CONFIG_MUXERS
119 {
121
124 "only codec g729 with 1 channel is supported by this format\n");
126 }
127
130
131 return 0;
132 }
133
135 {
138 int i;
139
142
145
147 for(i=0; i< 8 * 10; i++)
149
150 return 0;
151 }
152
156 .mime_type = "audio/bit",
157 .extensions = "bit",
162 };
163 #endif
void avio_wl16(AVIOContext *s, unsigned int val)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
int64_t pos
byte position in stream, -1 if unknown
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
AVInputFormat ff_bit_demuxer
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
#define AVERROR_EOF
End of file.
bitstream reader API header.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int probe(AVProbeData *p)
AVCodecContext * codec
Codec context associated with this stream.
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
enum AVMediaType codec_type
int sample_rate
samples per second
AVIOContext * pb
I/O context.
main external API structure.
static unsigned int get_bits1(GetBitContext *s)
static int read_header(AVFormatContext *s)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
This structure contains the data a format has to probe a file.
static int read_packet(AVFormatContext *s, AVPacket *pkt)
unsigned int avio_rl16(AVIOContext *s)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
int channels
number of audio channels
static void write_header(FFV1Context *f)
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
This structure stores compressed data.
static int write_packet(AVFormatContext *s1, AVPacket *pkt)