Revision 3cac899a

View differences:

configure
1162 1162
rdft_select="fft"
1163 1163

  
1164 1164
# decoders / encoders / hardware accelerators
1165
aac_decoder_select="mdct rdft aac_parser"
1165
aac_decoder_select="mdct rdft"
1166 1166
aac_encoder_select="mdct"
1167 1167
ac3_decoder_select="mdct ac3_parser"
1168 1168
alac_encoder_select="lpc"
......
1294 1294
# parsers
1295 1295
h264_parser_select="golomb h264dsp"
1296 1296

  
1297
# bitstream_filters
1298
aac_adtstoasc_bsf_select="aac_parser"
1299

  
1300 1297
# external libraries
1301 1298
libdirac_decoder_deps="libdirac !libschroedinger"
1302 1299
libdirac_encoder_deps="libdirac"
libavcodec/Makefile
42 42
OBJS-$(CONFIG_VDPAU)                   += vdpau.o
43 43

  
44 44
# decoders/encoders/hardware accelerators
45
OBJS-$(CONFIG_AAC_DECODER)             += aacdec.o aactab.o aacsbr.o aacps.o
45
OBJS-$(CONFIG_AAC_DECODER)             += aacdec.o aactab.o aacsbr.o aacps.o \
46
                                          aacadtsdec.o mpeg4audio.o
46 47
OBJS-$(CONFIG_AAC_ENCODER)             += aacenc.o aaccoder.o    \
47 48
                                          aacpsy.o aactab.o      \
48 49
                                          psymodel.o iirfilter.o \
......
550 551

  
551 552
# parsers
552 553
OBJS-$(CONFIG_AAC_PARSER)              += aac_parser.o aac_ac3_parser.o \
553
                                          mpeg4audio.o
554
                                          aacadtsdec.o mpeg4audio.o
554 555
OBJS-$(CONFIG_AC3_PARSER)              += ac3_parser.o ac3tab.o \
555 556
                                          aac_ac3_parser.o
556 557
OBJS-$(CONFIG_CAVSVIDEO_PARSER)        += cavs_parser.o
......
586 587
OBJS-$(CONFIG_VP8_PARSER)              += vp8_parser.o
587 588

  
588 589
# bitstream filters
589
OBJS-$(CONFIG_AAC_ADTSTOASC_BSF)          += aac_adtstoasc_bsf.o
590
OBJS-$(CONFIG_AAC_ADTSTOASC_BSF)          += aac_adtstoasc_bsf.o aacadtsdec.o \
591
                                             mpeg4audio.o
590 592
OBJS-$(CONFIG_CHOMP_BSF)                  += chomp_bsf.o
591 593
OBJS-$(CONFIG_DUMP_EXTRADATA_BSF)         += dump_extradata_bsf.o
592 594
OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF)       += h264_mp4toannexb_bsf.o
libavcodec/aac_adtstoasc_bsf.c
20 20
 */
21 21

  
22 22
#include "avcodec.h"
23
#include "aac_parser.h"
23
#include "aacadtsdec.h"
24 24
#include "put_bits.h"
25 25
#include "get_bits.h"
26 26
#include "mpeg4audio.h"
libavcodec/aac_parser.c
22 22

  
23 23
#include "parser.h"
24 24
#include "aac_ac3_parser.h"
25
#include "aac_parser.h"
25
#include "aacadtsdec.h"
26 26
#include "get_bits.h"
27 27
#include "mpeg4audio.h"
28 28

  
29
int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
30
{
31
    int size, rdb, ch, sr;
32
    int aot, crc_abs;
33

  
34
    if(get_bits(gbc, 12) != 0xfff)
35
        return AAC_AC3_PARSE_ERROR_SYNC;
36

  
37
    skip_bits1(gbc);             /* id */
38
    skip_bits(gbc, 2);           /* layer */
39
    crc_abs = get_bits1(gbc);    /* protection_absent */
40
    aot     = get_bits(gbc, 2);  /* profile_objecttype */
41
    sr      = get_bits(gbc, 4);  /* sample_frequency_index */
42
    if(!ff_mpeg4audio_sample_rates[sr])
43
        return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
44
    skip_bits1(gbc);             /* private_bit */
45
    ch      = get_bits(gbc, 3);  /* channel_configuration */
46

  
47
    skip_bits1(gbc);             /* original/copy */
48
    skip_bits1(gbc);             /* home */
49

  
50
    /* adts_variable_header */
51
    skip_bits1(gbc);             /* copyright_identification_bit */
52
    skip_bits1(gbc);             /* copyright_identification_start */
53
    size    = get_bits(gbc, 13); /* aac_frame_length */
54
    if(size < AAC_ADTS_HEADER_SIZE)
55
        return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
56

  
57
    skip_bits(gbc, 11);          /* adts_buffer_fullness */
58
    rdb = get_bits(gbc, 2);      /* number_of_raw_data_blocks_in_frame */
59

  
60
    hdr->object_type    = aot + 1;
61
    hdr->chan_config    = ch;
62
    hdr->crc_absent     = crc_abs;
63
    hdr->num_aac_frames = rdb + 1;
64
    hdr->sampling_index = sr;
65
    hdr->sample_rate    = ff_mpeg4audio_sample_rates[sr];
66
    hdr->samples        = (rdb + 1) * 1024;
67
    hdr->bit_rate       = size * 8 * hdr->sample_rate / hdr->samples;
68

  
69
    return size;
70
}
71

  
72 29
static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info,
73 30
        int *need_next_header, int *new_frame_start)
74 31
{
libavcodec/aac_parser.h
1
/*
2
 * AAC parser prototypes
3
 * Copyright (c) 2003 Fabrice Bellard
4
 * Copyright (c) 2003 Michael Niedermayer
5
 *
6
 * This file is part of FFmpeg.
7
 *
8
 * FFmpeg is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * FFmpeg is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
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
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
 */
22

  
23
#ifndef AVCODEC_AAC_PARSER_H
24
#define AVCODEC_AAC_PARSER_H
25

  
26
#include <stdint.h>
27
#include "aac_ac3_parser.h"
28
#include "get_bits.h"
29

  
30
#define AAC_ADTS_HEADER_SIZE 7
31

  
32
typedef struct {
33
    uint32_t sample_rate;
34
    uint32_t samples;
35
    uint32_t bit_rate;
36
    uint8_t  crc_absent;
37
    uint8_t  object_type;
38
    uint8_t  sampling_index;
39
    uint8_t  chan_config;
40
    uint8_t  num_aac_frames;
41
} AACADTSHeaderInfo;
42

  
43
/**
44
 * Parse AAC frame header.
45
 * Parse the ADTS frame header to the end of the variable header, which is
46
 * the first 54 bits.
47
 * @param gbc BitContext containing the first 54 bits of the frame.
48
 * @param hdr Pointer to struct where header info is written.
49
 * @return Returns 0 on success, -1 if there is a sync word mismatch,
50
 * -2 if the version element is invalid, -3 if the sample rate
51
 * element is invalid, or -4 if the bit rate element is invalid.
52
 */
53
int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr);
54

  
55
#endif /* AVCODEC_AAC_PARSER_H */
libavcodec/aacadtsdec.c
1
/*
2
 * Audio and Video frame extraction
3
 * Copyright (c) 2003 Fabrice Bellard
4
 * Copyright (c) 2003 Michael Niedermayer
5
 * Copyright (c) 2009 Alex Converse
6
 *
7
 * This file is part of FFmpeg.
8
 *
9
 * FFmpeg is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU Lesser General Public
11
 * License as published by the Free Software Foundation; either
12
 * version 2.1 of the License, or (at your option) any later version.
13
 *
14
 * FFmpeg is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 * Lesser General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public
20
 * License along with FFmpeg; if not, write to the Free Software
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
 */
23

  
24
#include "aac_ac3_parser.h"
25
#include "aacadtsdec.h"
26
#include "get_bits.h"
27
#include "mpeg4audio.h"
28

  
29
int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
30
{
31
    int size, rdb, ch, sr;
32
    int aot, crc_abs;
33

  
34
    if(get_bits(gbc, 12) != 0xfff)
35
        return AAC_AC3_PARSE_ERROR_SYNC;
36

  
37
    skip_bits1(gbc);             /* id */
38
    skip_bits(gbc, 2);           /* layer */
39
    crc_abs = get_bits1(gbc);    /* protection_absent */
40
    aot     = get_bits(gbc, 2);  /* profile_objecttype */
41
    sr      = get_bits(gbc, 4);  /* sample_frequency_index */
42
    if(!ff_mpeg4audio_sample_rates[sr])
43
        return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
44
    skip_bits1(gbc);             /* private_bit */
45
    ch      = get_bits(gbc, 3);  /* channel_configuration */
46

  
47
    skip_bits1(gbc);             /* original/copy */
48
    skip_bits1(gbc);             /* home */
49

  
50
    /* adts_variable_header */
51
    skip_bits1(gbc);             /* copyright_identification_bit */
52
    skip_bits1(gbc);             /* copyright_identification_start */
53
    size    = get_bits(gbc, 13); /* aac_frame_length */
54
    if(size < AAC_ADTS_HEADER_SIZE)
55
        return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
56

  
57
    skip_bits(gbc, 11);          /* adts_buffer_fullness */
58
    rdb = get_bits(gbc, 2);      /* number_of_raw_data_blocks_in_frame */
59

  
60
    hdr->object_type    = aot + 1;
61
    hdr->chan_config    = ch;
62
    hdr->crc_absent     = crc_abs;
63
    hdr->num_aac_frames = rdb + 1;
64
    hdr->sampling_index = sr;
65
    hdr->sample_rate    = ff_mpeg4audio_sample_rates[sr];
66
    hdr->samples        = (rdb + 1) * 1024;
67
    hdr->bit_rate       = size * 8 * hdr->sample_rate / hdr->samples;
68

  
69
    return size;
70
}
libavcodec/aacadtsdec.h
1
/*
2
 * AAC ADTS header decoding prototypes and structures
3
 * Copyright (c) 2003 Fabrice Bellard
4
 * Copyright (c) 2003 Michael Niedermayer
5
 *
6
 * This file is part of FFmpeg.
7
 *
8
 * FFmpeg is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * FFmpeg is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
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
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
 */
22

  
23
#ifndef AVCODEC_AACADTSDEC_H
24
#define AVCODEC_AACADTSDEC_H
25

  
26
#include <stdint.h>
27
#include "get_bits.h"
28

  
29
#define AAC_ADTS_HEADER_SIZE 7
30

  
31
typedef struct {
32
    uint32_t sample_rate;
33
    uint32_t samples;
34
    uint32_t bit_rate;
35
    uint8_t  crc_absent;
36
    uint8_t  object_type;
37
    uint8_t  sampling_index;
38
    uint8_t  chan_config;
39
    uint8_t  num_aac_frames;
40
} AACADTSHeaderInfo;
41

  
42
/**
43
 * Parse AAC frame header.
44
 * Parse the ADTS frame header to the end of the variable header, which is
45
 * the first 54 bits.
46
 * @param gbc BitContext containing the first 54 bits of the frame.
47
 * @param hdr Pointer to struct where header info is written.
48
 * @return Returns 0 on success, -1 if there is a sync word mismatch,
49
 * -2 if the version element is invalid, -3 if the sample rate
50
 * element is invalid, or -4 if the bit rate element is invalid.
51
 */
52
int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr);
53

  
54
#endif /* AVCODEC_AACADTSDEC_H */
libavcodec/aacdec.c
90 90
#include "sbr.h"
91 91
#include "aacsbr.h"
92 92
#include "mpeg4audio.h"
93
#include "aac_parser.h"
93
#include "aacadtsdec.h"
94 94

  
95 95
#include <assert.h>
96 96
#include <errno.h>
libavformat/spdif.c
43 43
#include "avformat.h"
44 44
#include "libavcodec/ac3.h"
45 45
#include "libavcodec/dca.h"
46
#include "libavcodec/aac_parser.h"
46
#include "libavcodec/aacadtsdec.h"
47 47

  
48 48
#define SYNCWORD1 0xF872
49 49
#define SYNCWORD2 0x4E1F

Also available in: Unified diff