-/*
+/*
* amr file format
* Copyright (c) 2001 ffmpeg project
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
static const unsigned char AMR_header [] = "#!AMR\n";
static const unsigned char AMRWB_header [] = "#!AMR-WB\n";
+#ifdef CONFIG_MUXERS
static int amr_write_header(AVFormatContext *s)
{
ByteIOContext *pb = &s->pb;
- AVCodecContext *enc = &s->streams[0]->codec;
+ AVCodecContext *enc = s->streams[0]->codec;
s->priv_data = NULL;
{
return 0;
}
+#endif /* CONFIG_MUXERS */
static int amr_probe(AVProbeData *p)
{
- //Only check for "#!AMR" which could be amr-wb, amr-nb.
- //This will also trigger multichannel files: "#!AMR_MC1.0\n" and
+ //Only check for "#!AMR" which could be amr-wb, amr-nb.
+ //This will also trigger multichannel files: "#!AMR_MC1.0\n" and
//"#!AMR-WB_MC1.0\n" (not supported)
if (p->buf_size < 5)
{
return AVERROR_NOMEM;
}
-
- st->codec.codec_type = CODEC_TYPE_AUDIO;
- st->codec.codec_tag = CODEC_ID_AMR_WB;
- st->codec.codec_id = CODEC_ID_AMR_WB;
- st->codec.channels = 1;
- st->codec.sample_rate = 16000;
+
+ st->codec->codec_type = CODEC_TYPE_AUDIO;
+ st->codec->codec_tag = MKTAG('s', 'a', 'w', 'b');
+ st->codec->codec_id = CODEC_ID_AMR_WB;
+ st->codec->channels = 1;
+ st->codec->sample_rate = 16000;
}
else
{
{
return AVERROR_NOMEM;
}
-
- st->codec.codec_type = CODEC_TYPE_AUDIO;
- st->codec.codec_tag = CODEC_ID_AMR_NB;
- st->codec.codec_id = CODEC_ID_AMR_NB;
- st->codec.channels = 1;
- st->codec.sample_rate = 8000;
+
+ st->codec->codec_type = CODEC_TYPE_AUDIO;
+ st->codec->codec_tag = MKTAG('s', 'a', 'm', 'r');
+ st->codec->codec_id = CODEC_ID_AMR_NB;
+ st->codec->channels = 1;
+ st->codec->sample_rate = 8000;
}
return 0;
static int amr_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
- AVCodecContext *enc = &s->streams[0]->codec;
+ AVCodecContext *enc = s->streams[0]->codec;
if (enc->codec_id == CODEC_ID_AMR_NB)
{
uint8_t toc, q, ft;
int read;
int size;
-
+
if (url_feof(&s->pb))
{
return AVERROR_IO;
}
-
+
toc=get_byte(&s->pb);
q = (toc >> 2) & 0x01;
ft = (toc >> 3) & 0x0F;
-
+
size=packed_size[ft];
-
+
if (av_new_packet(pkt, size+1))
{
return AVERROR_IO;
}
pkt->stream_index = 0;
-
+ pkt->pos= url_ftell(&s->pb);
pkt->data[0]=toc;
-
+
read = get_buffer(&s->pb, pkt->data+1, size);
-
+
if (read != size)
{
av_free_packet(pkt);
return AVERROR_IO;
}
-
+
return 0;
}
else if(enc->codec_id == CODEC_ID_AMR_WB)
uint8_t toc, mode;
int read;
int size;
-
+
if (url_feof(&s->pb))
{
return AVERROR_IO;
}
-
+
toc=get_byte(&s->pb);
mode = (uint8_t)((toc >> 3) & 0x0F);
size = packed_size[mode];
-
+
if ( (size==0) || av_new_packet(pkt, size))
{
return AVERROR_IO;
}
-
+
pkt->stream_index = 0;
+ pkt->pos= url_ftell(&s->pb);
pkt->data[0]=toc;
-
+
read = get_buffer(&s->pb, pkt->data+1, size-1);
-
+
if (read != (size-1))
{
av_free_packet(pkt);
return AVERROR_IO;
}
-
+
return 0;
}
else
amr_read_close,
};
+#ifdef CONFIG_MUXERS
static AVOutputFormat amr_oformat = {
"amr",
"3gpp amr file format",
amr_write_packet,
amr_write_trailer,
};
+#endif
int amr_init(void)
{
av_register_input_format(&amr_iformat);
+#ifdef CONFIG_MUXERS
av_register_output_format(&amr_oformat);
+#endif
return 0;
}