3
3
* Copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@smartjog.com>
4
4
* Mans Rullgard <mans@mansr.com>
6
* This file is part of FFmpeg.
6
* This file is part of Libav.
8
* FFmpeg is free software; you can redistribute it and/or
8
* Libav is free software; you can redistribute it and/or
9
9
* modify it under the terms of the GNU Lesser General Public
10
10
* License as published by the Free Software Foundation; either
11
11
* version 2.1 of the License, or (at your option) any later version.
13
* FFmpeg is distributed in the hope that it will be useful,
13
* Libav is distributed in the hope that it will be useful,
14
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
16
* Lesser General Public License for more details.
18
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with FFmpeg; if not, write to the Free Software
19
* License along with Libav; if not, write to the Free Software
20
20
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
23
#include "libavcodec/get_bits.h"
24
24
#include "libavcodec/put_bits.h"
25
25
#include "libavcodec/avcodec.h"
26
#include "libavcodec/mpeg4audio.h"
26
27
#include "avformat.h"
34
MPEG4AudioConfig m4ac;
34
37
init_get_bits(&gb, buf, size * 8);
35
adts->objecttype = get_bits(&gb, 5) - 1;
36
adts->sample_rate_index = get_bits(&gb, 4);
37
adts->channel_conf = get_bits(&gb, 4);
38
off = ff_mpeg4audio_get_config(&m4ac, buf, size);
41
skip_bits_long(&gb, off);
42
adts->objecttype = m4ac.object_type - 1;
43
adts->sample_rate_index = m4ac.sampling_index;
44
adts->channel_conf = m4ac.chan_config;
39
46
if (adts->objecttype > 3U) {
40
47
av_log(s, AV_LOG_ERROR, "MPEG-4 AOT %d is not allowed in ADTS\n", adts->objecttype+1);
52
59
av_log(s, AV_LOG_ERROR, "Scalable configurations are not allowed in ADTS\n");
55
if (get_bits(&gb, 1)) {
56
av_log_missing_feature(s, "Signaled SBR or PS", 0);
59
62
if (!adts->channel_conf) {
60
63
init_put_bits(&pb, adts->pce_data, MAX_PCE_SIZE);
74
77
ADTSContext *adts = s->priv_data;
75
78
AVCodecContext *avc = s->streams[0]->codec;
77
if(avc->extradata_size > 0 &&
80
if (avc->extradata_size > 0 &&
78
81
ff_adts_decode_extradata(s, adts, avc->extradata, avc->extradata_size) < 0)
115
118
static int adts_write_packet(AVFormatContext *s, AVPacket *pkt)
117
120
ADTSContext *adts = s->priv_data;
118
ByteIOContext *pb = s->pb;
121
AVIOContext *pb = s->pb;
119
122
uint8_t buf[ADTS_HEADER_SIZE];
123
if(adts->write_adts) {
126
if (adts->write_adts) {
124
127
ff_adts_write_frame_header(adts, buf, pkt->size, adts->pce_size);
125
put_buffer(pb, buf, ADTS_HEADER_SIZE);
127
put_buffer(pb, adts->pce_data, adts->pce_size);
128
avio_write(pb, buf, ADTS_HEADER_SIZE);
129
if (adts->pce_size) {
130
avio_write(pb, adts->pce_data, adts->pce_size);
128
131
adts->pce_size = 0;
131
put_buffer(pb, pkt->data, pkt->size);
132
put_flush_packet(pb);
134
avio_write(pb, pkt->data, pkt->size);
137
AVOutputFormat adts_muxer = {
140
AVOutputFormat ff_adts_muxer = {
139
142
NULL_IF_CONFIG_SMALL("ADTS AAC"),