2
* AU encoder and decoder
3
3
* Copyright (c) 2001 Fabrice Bellard.
5
* This library is free software; you can redistribute it and/or
5
* This file is part of FFmpeg.
7
* FFmpeg is free software; you can redistribute it and/or
6
8
* modify it under the terms of the GNU Lesser General Public
7
9
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* version 2.1 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
12
* FFmpeg is distributed in the hope that it will be useful,
11
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
15
* Lesser General Public License for more details.
15
17
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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
28
30
#include "avformat.h"
31
#include "allformats.h"
31
34
/* if we don't know the size in advance */
32
35
#define AU_UNKOWN_SIZE ((uint32_t)(~0))
34
37
/* The ffmpeg codecs we support, and the IDs they have in the file */
35
static const CodecTag codec_au_tags[] = {
38
static const AVCodecTag codec_au_tags[] = {
36
39
{ CODEC_ID_PCM_MULAW, 1 },
37
40
{ CODEC_ID_PCM_S16BE, 3 },
38
41
{ CODEC_ID_PCM_ALAW, 27 },
42
46
/* AUDIO_FILE header */
43
47
static int put_au_header(ByteIOContext *pb, AVCodecContext *enc)
45
49
if(!enc->codec_tag)
46
enc->codec_tag = codec_get_tag(codec_au_tags, enc->codec_id);
49
51
put_tag(pb, ".snd"); /* magic number */
50
52
put_be32(pb, 24); /* header size */
74
static int au_write_packet(AVFormatContext *s, int stream_index_ptr,
75
const uint8_t *buf, int size, int64_t pts)
76
static int au_write_packet(AVFormatContext *s, AVPacket *pkt)
77
78
ByteIOContext *pb = &s->pb;
78
put_buffer(pb, buf, size);
79
put_buffer(pb, pkt->data, pkt->size);
142
144
st = av_new_stream(s, 0);
145
st->codec.codec_type = CODEC_TYPE_AUDIO;
146
st->codec.codec_tag = id;
147
st->codec.codec_id = codec;
148
st->codec.channels = channels;
149
st->codec.sample_rate = rate;
147
st->codec->codec_type = CODEC_TYPE_AUDIO;
148
st->codec->codec_tag = id;
149
st->codec->codec_id = codec;
150
st->codec->channels = channels;
151
st->codec->sample_rate = rate;
152
av_set_pts_info(st, 64, 1, rate);
160
163
if (url_feof(&s->pb))
162
if (av_new_packet(pkt, MAX_SIZE))
165
ret= av_get_packet(&s->pb, pkt, MAX_SIZE);
164
168
pkt->stream_index = 0;
166
ret = get_buffer(&s->pb, pkt->data, pkt->size);
169
170
/* note: we need to modify the packet size here to handle the last