* commit 'b5f19f7478492307e4b4763aeac3180faf50e17f': aac: Split function to parse ADTS header data into public and private part
Unified · Split
| @@ -2135,6 +2135,7 @@ HAVE_LIST=" · 2134 unmodified lines | |||
| 2135 | CONFIG_EXTRA=" | 2135 | CONFIG_EXTRA=" |
| 2136 | aandcttables | 2136 | aandcttables |
| 2137 | ac3dsp | 2137 | ac3dsp |
| 2138 | adts_header | ||
| 2138 | audio_frame_queue | 2139 | audio_frame_queue |
| 2139 | audiodsp | 2140 | audiodsp |
| 2140 | blockdsp | 2141 | blockdsp |
| @@ -2421,7 +2422,7 @@ vc1dsp_select="h264chroma qpeldsp startcode" · 280 unmodified lines | |||
| 2421 | rdft_select="fft" | 2422 | rdft_select="fft" |
| 2422 | 2423 | ||
| 2423 | # decoders / encoders | 2424 | # decoders / encoders |
| 2424 | aac_decoder_select="mdct15 mdct sinewin" | 2425 | aac_decoder_select="adts_header mdct15 mdct sinewin" |
| 2425 | aac_fixed_decoder_select="mdct sinewin" | 2426 | aac_fixed_decoder_select="mdct sinewin" |
| 2426 | aac_encoder_select="audio_frame_queue iirfilter lpc mdct sinewin" | 2427 | aac_encoder_select="audio_frame_queue iirfilter lpc mdct sinewin" |
| 2427 | aac_latm_decoder_select="aac_decoder aac_latm_parser" | 2428 | aac_latm_decoder_select="aac_decoder aac_latm_parser" |
| @@ -2873,6 +2874,7 @@ vp9_v4l2m2m_decoder_deps="v4l2_m2m vp9_v4l2_m2m" · 445 unmodified lines | |||
| 2873 | wmv3_crystalhd_decoder_select="crystalhd" | 2874 | wmv3_crystalhd_decoder_select="crystalhd" |
| 2874 | 2875 | ||
| 2875 | # parsers | 2876 | # parsers |
| 2877 | aac_parser_select="adts_header" | ||
| 2876 | h264_parser_select="golomb h264dsp h264parse" | 2878 | h264_parser_select="golomb h264dsp h264parse" |
| 2877 | hevc_parser_select="hevcparse" | 2879 | hevc_parser_select="hevcparse" |
| 2878 | mpegaudio_parser_select="mpegaudioheader" | 2880 | mpegaudio_parser_select="mpegaudioheader" |
| @@ -2881,6 +2883,7 @@ mpeg4video_parser_select="h263dsp mpegvideo qpeldsp" · 2 unmodified lines | |||
| 2881 | vc1_parser_select="vc1dsp" | 2883 | vc1_parser_select="vc1dsp" |
| 2882 | 2884 | ||
| 2883 | # bitstream_filters | 2885 | # bitstream_filters |
| 2886 | aac_adtstoasc_bsf_select="adts_header" | ||
| 2884 | h264_metadata_bsf_select="cbs_h264" | 2887 | h264_metadata_bsf_select="cbs_h264" |
| 2885 | h264_redundant_pps_bsf_select="cbs_h264" | 2888 | h264_redundant_pps_bsf_select="cbs_h264" |
| 2886 | hevc_metadata_bsf_select="cbs_h265" | 2889 | hevc_metadata_bsf_select="cbs_h265" |
| @@ -3047,7 +3050,8 @@ sap_demuxer_select="sdp_demuxer" · 160 unmodified lines | |||
| 3047 | sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain" | 3050 | sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain" |
| 3048 | sdp_demuxer_select="rtpdec" | 3051 | sdp_demuxer_select="rtpdec" |
| 3049 | smoothstreaming_muxer_select="ismv_muxer" | 3052 | smoothstreaming_muxer_select="ismv_muxer" |
| 3050 | spdif_muxer_select="aac_parser" | 3053 | spdif_demuxer_select="adts_header" |
| 3054 | spdif_muxer_select="adts_header" | ||
| 3051 | spx_muxer_select="ogg_muxer" | 3055 | spx_muxer_select="ogg_muxer" |
| 3052 | swf_demuxer_suggest="zlib" | 3056 | swf_demuxer_suggest="zlib" |
| 3053 | tak_demuxer_select="tak_parser" | 3057 | tak_demuxer_select="tak_parser" |
| @@ -184,7 +184,7 @@ e.g. @samp{ff_w64_demuxer}. · 183 unmodified lines | |||
| 184 | @item | 184 | @item |
| 185 | For variables and functions visible outside of file scope, used internally | 185 | For variables and functions visible outside of file scope, used internally |
| 186 | across multiple libraries, use @code{avpriv_} as prefix, for example, | 186 | across multiple libraries, use @code{avpriv_} as prefix, for example, |
| 187 | @samp{avpriv_aac_parse_header}. | 187 | @samp{avpriv_report_missing_feature}. |
| 188 | 188 | ||
| 189 | @item | 189 | @item |
| 190 | Each library has its own prefix for public symbols, in addition to the | 190 | Each library has its own prefix for public symbols, in addition to the |
| @@ -2,6 +2,7 @@ NAME = avcodec · 1 unmodified line | |||
| 2 | DESC = FFmpeg codec library | 2 | DESC = FFmpeg codec library |
| 3 | 3 | ||
| 4 | HEADERS = ac3_parser.h \ | 4 | HEADERS = ac3_parser.h \ |
| 5 | adts_parser.h \ | ||
| 5 | avcodec.h \ | 6 | avcodec.h \ |
| 6 | avdct.h \ | 7 | avdct.h \ |
| 7 | avfft.h \ | 8 | avfft.h \ |
| @@ -20,6 +21,7 @@ HEADERS = ac3_parser.h \ · 12 unmodified lines | |||
| 20 | xvmc.h \ | 21 | xvmc.h \ |
| 21 | 22 | ||
| 22 | OBJS = ac3_parser.o \ | 23 | OBJS = ac3_parser.o \ |
| 24 | adts_parser.o \ | ||
| 23 | allcodecs.o \ | 25 | allcodecs.o \ |
| 24 | avdct.o \ | 26 | avdct.o \ |
| 25 | avpacket.o \ | 27 | avpacket.o \ |
| @@ -52,6 +54,7 @@ OBJS = ac3_parser.o \ · 26 unmodified lines | |||
| 52 | # subsystems | 54 | # subsystems |
| 53 | OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o | 55 | OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o |
| 54 | OBJS-$(CONFIG_AC3DSP) += ac3dsp.o ac3.o ac3tab.o | 56 | OBJS-$(CONFIG_AC3DSP) += ac3dsp.o ac3.o ac3tab.o |
| 57 | OBJS-$(CONFIG_ADTS_HEADER) += adts_header.o mpeg4audio.o | ||
| 55 | OBJS-$(CONFIG_AUDIO_FRAME_QUEUE) += audio_frame_queue.o | 58 | OBJS-$(CONFIG_AUDIO_FRAME_QUEUE) += audio_frame_queue.o |
| 56 | OBJS-$(CONFIG_AUDIODSP) += audiodsp.o | 59 | OBJS-$(CONFIG_AUDIODSP) += audiodsp.o |
| 57 | OBJS-$(CONFIG_BLOCKDSP) += blockdsp.o | 60 | OBJS-$(CONFIG_BLOCKDSP) += blockdsp.o |
| @@ -148,10 +151,10 @@ OBJS-$(CONFIG_ZERO12V_DECODER) += 012v.o · 90 unmodified lines | |||
| 148 | OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o | 151 | OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o |
| 149 | OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o | 152 | OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o |
| 150 | OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps_float.o \ | 153 | OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps_float.o \ |
| 151 | aacadtsdec.o mpeg4audio.o kbdwin.o \ | 154 | mpeg4audio.o kbdwin.o \ |
| 152 | sbrdsp.o aacpsdsp_float.o cbrt_data.o | 155 | sbrdsp.o aacpsdsp_float.o cbrt_data.o |
| 153 | OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o aacps_fixed.o \ | 156 | OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o aacps_fixed.o \ |
| 154 | aacadtsdec.o mpeg4audio.o kbdwin.o \ | 157 | mpeg4audio.o kbdwin.o \ |
| 155 | sbrdsp_fixed.o aacpsdsp_fixed.o cbrt_data_fixed.o | 158 | sbrdsp_fixed.o aacpsdsp_fixed.o cbrt_data_fixed.o |
| 156 | OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacenctab.o \ | 159 | OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacenctab.o \ |
| 157 | aacpsy.o aactab.o \ | 160 | aacpsy.o aactab.o \ |
| @@ -880,7 +883,6 @@ OBJS-$(CONFIG_MXF_MUXER) += dnxhddata.o · 722 unmodified lines | |||
| 880 | OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o | 883 | OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o |
| 881 | OBJS-$(CONFIG_NUT_DEMUXER) += mpegaudiodata.o mpeg4audio.o | 884 | OBJS-$(CONFIG_NUT_DEMUXER) += mpegaudiodata.o mpeg4audio.o |
| 882 | OBJS-$(CONFIG_RTP_MUXER) += mpeg4audio.o | 885 | OBJS-$(CONFIG_RTP_MUXER) += mpeg4audio.o |
| 883 | OBJS-$(CONFIG_SPDIF_DEMUXER) += aacadtsdec.o mpeg4audio.o | ||
| 884 | OBJS-$(CONFIG_SPDIF_MUXER) += dca.o | 886 | OBJS-$(CONFIG_SPDIF_MUXER) += dca.o |
| 885 | OBJS-$(CONFIG_TAK_DEMUXER) += tak.o | 887 | OBJS-$(CONFIG_TAK_DEMUXER) += tak.o |
| 886 | OBJS-$(CONFIG_WEBM_MUXER) += mpeg4audio.o | 888 | OBJS-$(CONFIG_WEBM_MUXER) += mpeg4audio.o |
| @@ -957,7 +959,7 @@ OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER) += libzvbi-teletextdec.o ass.o · 70 unmodified lines | |||
| 957 | # parsers | 959 | # parsers |
| 958 | OBJS-$(CONFIG_AAC_LATM_PARSER) += latm_parser.o | 960 | OBJS-$(CONFIG_AAC_LATM_PARSER) += latm_parser.o |
| 959 | OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o \ | 961 | OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o \ |
| 960 | aacadtsdec.o mpeg4audio.o | 962 | mpeg4audio.o |
| 961 | OBJS-$(CONFIG_AC3_PARSER) += ac3tab.o aac_ac3_parser.o | 963 | OBJS-$(CONFIG_AC3_PARSER) += ac3tab.o aac_ac3_parser.o |
| 962 | OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o adx.o | 964 | OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o adx.o |
| 963 | OBJS-$(CONFIG_BMP_PARSER) += bmp_parser.o | 965 | OBJS-$(CONFIG_BMP_PARSER) += bmp_parser.o |
| @@ -1003,8 +1005,7 @@ OBJS-$(CONFIG_VP9_PARSER) += vp9_parser.o · 39 unmodified lines | |||
| 1003 | OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o | 1005 | OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o |
| 1004 | 1006 | ||
| 1005 | # bitstream filters | 1007 | # bitstream filters |
| 1006 | OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o aacadtsdec.o \ | 1008 | OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o mpeg4audio.o |
| 1007 | mpeg4audio.o | ||
| 1008 | OBJS-$(CONFIG_CHOMP_BSF) += chomp_bsf.o | 1009 | OBJS-$(CONFIG_CHOMP_BSF) += chomp_bsf.o |
| 1009 | OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o | 1010 | OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o |
| 1010 | OBJS-$(CONFIG_DCA_CORE_BSF) += dca_core_bsf.o | 1011 | OBJS-$(CONFIG_DCA_CORE_BSF) += dca_core_bsf.o |
| @@ -19,8 +19,9 @@ · 18 unmodified lines | |||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #include "adts_header.h" | ||
| 23 | #include "adts_parser.h" | ||
| 22 | #include "avcodec.h" | 24 | #include "avcodec.h" |
| 23 | #include "aacadtsdec.h" | ||
| 24 | #include "bsf.h" | 25 | #include "bsf.h" |
| 25 | #include "put_bits.h" | 26 | #include "put_bits.h" |
| 26 | #include "get_bits.h" | 27 | #include "get_bits.h" |
| @@ -52,12 +53,12 @@ static int aac_adtstoasc_filter(AVBSFContext *bsfc, AVPacket *out) · 25 unmodified lines | |||
| 52 | if (bsfc->par_in->extradata && in->size >= 2 && (AV_RB16(in->data) >> 4) != 0xfff) | 53 | if (bsfc->par_in->extradata && in->size >= 2 && (AV_RB16(in->data) >> 4) != 0xfff) |
| 53 | goto finish; | 54 | goto finish; |
| 54 | 55 | ||
| 55 | if (in->size < AAC_ADTS_HEADER_SIZE) | 56 | if (in->size < AV_AAC_ADTS_HEADER_SIZE) |
| 56 | goto packet_too_small; | 57 | goto packet_too_small; |
| 57 | 58 | ||
| 58 | init_get_bits(&gb, in->data, AAC_ADTS_HEADER_SIZE * 8); | 59 | init_get_bits(&gb, in->data, AV_AAC_ADTS_HEADER_SIZE * 8); |
| 59 | 60 | ||
| 60 | if (avpriv_aac_parse_header(&gb, &hdr) < 0) { | 61 | if (ff_adts_header_parse(&gb, &hdr) < 0) { |
| 61 | av_log(bsfc, AV_LOG_ERROR, "Error parsing ADTS frame header!\n"); | 62 | av_log(bsfc, AV_LOG_ERROR, "Error parsing ADTS frame header!\n"); |
| 62 | ret = AVERROR_INVALIDDATA; | 63 | ret = AVERROR_INVALIDDATA; |
| 63 | goto fail; | 64 | goto fail; |
| @@ -70,10 +71,10 @@ static int aac_adtstoasc_filter(AVBSFContext *bsfc, AVPacket *out) · 6 unmodified lines | |||
| 70 | goto fail; | 71 | goto fail; |
| 71 | } | 72 | } |
| 72 | 73 | ||
| 73 | in->size -= AAC_ADTS_HEADER_SIZE + 2 * !hdr.crc_absent; | 74 | in->size -= AV_AAC_ADTS_HEADER_SIZE + 2 * !hdr.crc_absent; |
| 74 | if (in->size <= 0) | 75 | if (in->size <= 0) |
| 75 | goto packet_too_small; | 76 | goto packet_too_small; |
| 76 | in->data += AAC_ADTS_HEADER_SIZE + 2 * !hdr.crc_absent; | 77 | in->data += AV_AAC_ADTS_HEADER_SIZE + 2 * !hdr.crc_absent; |
| 77 | 78 | ||
| 78 | if (!ctx->first_frame_done) { | 79 | if (!ctx->first_frame_done) { |
| 79 | int pce_size = 0; | 80 | int pce_size = 0; |
| @@ -22,7 +22,8 @@ · 21 unmodified lines | |||
| 22 | 22 | ||
| 23 | #include "parser.h" | 23 | #include "parser.h" |
| 24 | #include "aac_ac3_parser.h" | 24 | #include "aac_ac3_parser.h" |
| 25 | #include "aacadtsdec.h" | 25 | #include "adts_header.h" |
| 26 | #include "adts_parser.h" | ||
| 26 | #include "get_bits.h" | 27 | #include "get_bits.h" |
| 27 | #include "mpeg4audio.h" | 28 | #include "mpeg4audio.h" |
| 28 | 29 | ||
| @@ -38,9 +39,10 @@ static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info, · 9 unmodified lines | |||
| 38 | } tmp; | 39 | } tmp; |
| 39 | 40 | ||
| 40 | tmp.u64 = av_be2ne64(state); | 41 | tmp.u64 = av_be2ne64(state); |
| 41 | init_get_bits(&bits, tmp.u8+8-AAC_ADTS_HEADER_SIZE, AAC_ADTS_HEADER_SIZE * 8); | 42 | init_get_bits(&bits, tmp.u8 + 8 - AV_AAC_ADTS_HEADER_SIZE, |
| 43 | AV_AAC_ADTS_HEADER_SIZE * 8); | ||
| 42 | 44 | ||
| 43 | if ((size = avpriv_aac_parse_header(&bits, &hdr)) < 0) | 45 | if ((size = ff_adts_header_parse(&bits, &hdr)) < 0) |
| 44 | return 0; | 46 | return 0; |
| 45 | *need_next_header = 0; | 47 | *need_next_header = 0; |
| 46 | *new_frame_start = 1; | 48 | *new_frame_start = 1; |
| @@ -54,7 +56,7 @@ static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info, · 7 unmodified lines | |||
| 54 | static av_cold int aac_parse_init(AVCodecParserContext *s1) | 56 | static av_cold int aac_parse_init(AVCodecParserContext *s1) |
| 55 | { | 57 | { |
| 56 | AACAC3ParseContext *s = s1->priv_data; | 58 | AACAC3ParseContext *s = s1->priv_data; |
| 57 | s->header_size = AAC_ADTS_HEADER_SIZE; | 59 | s->header_size = AV_AAC_ADTS_HEADER_SIZE; |
| 58 | s->sync = aac_sync; | 60 | s->sync = aac_sync; |
| 59 | return 0; | 61 | return 0; |
| 60 | } | 62 | } |
| @@ -50,11 +50,11 @@ · 49 unmodified lines | |||
| 50 | #include "aac.h" | 50 | #include "aac.h" |
| 51 | #include "aactab.h" | 51 | #include "aactab.h" |
| 52 | #include "aacdectab.h" | 52 | #include "aacdectab.h" |
| 53 | #include "adts_header.h" | ||
| 53 | #include "cbrt_data.h" | 54 | #include "cbrt_data.h" |
| 54 | #include "sbr.h" | 55 | #include "sbr.h" |
| 55 | #include "aacsbr.h" | 56 | #include "aacsbr.h" |
| 56 | #include "mpeg4audio.h" | 57 | #include "mpeg4audio.h" |
| 57 | #include "aacadtsdec.h" | ||
| 58 | #include "profiles.h" | 58 | #include "profiles.h" |
| 59 | #include "libavutil/intfloat.h" | 59 | #include "libavutil/intfloat.h" |
| 60 | 60 | ||
| @@ -75,11 +75,11 @@ · 74 unmodified lines | |||
| 75 | #include "aac.h" | 75 | #include "aac.h" |
| 76 | #include "aactab.h" | 76 | #include "aactab.h" |
| 77 | #include "aacdectab.h" | 77 | #include "aacdectab.h" |
| 78 | #include "adts_header.h" | ||
| 78 | #include "cbrt_data.h" | 79 | #include "cbrt_data.h" |
| 79 | #include "sbr.h" | 80 | #include "sbr.h" |
| 80 | #include "aacsbr.h" | 81 | #include "aacsbr.h" |
| 81 | #include "mpeg4audio.h" | 82 | #include "mpeg4audio.h" |
| 82 | #include "aacadtsdec.h" | ||
| 83 | #include "profiles.h" | 83 | #include "profiles.h" |
| 84 | #include "libavutil/intfloat.h" | 84 | #include "libavutil/intfloat.h" |
| 85 | 85 | ||
| @@ -2955,7 +2955,7 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) · 2954 unmodified lines | |||
| 2955 | uint8_t layout_map[MAX_ELEM_ID*4][3]; | 2955 | uint8_t layout_map[MAX_ELEM_ID*4][3]; |
| 2956 | int layout_map_tags, ret; | 2956 | int layout_map_tags, ret; |
| 2957 | 2957 | ||
| 2958 | size = avpriv_aac_parse_header(gb, &hdr_info); | 2958 | size = ff_adts_header_parse(gb, &hdr_info); |
| 2959 | if (size > 0) { | 2959 | if (size > 0) { |
| 2960 | if (!ac->warned_num_aac_frames && hdr_info.num_aac_frames != 1) { | 2960 | if (!ac->warned_num_aac_frames && hdr_info.num_aac_frames != 1) { |
| 2961 | // This is 2 for "VLB " audio in NSV files. | 2961 | // This is 2 for "VLB " audio in NSV files. |
| @@ -22,11 +22,12 @@ · 21 unmodified lines | |||
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | #include "aac_ac3_parser.h" | 24 | #include "aac_ac3_parser.h" |
| 25 | #include "aacadtsdec.h" | 25 | #include "adts_header.h" |
| 26 | #include "adts_parser.h" | ||
| 26 | #include "get_bits.h" | 27 | #include "get_bits.h" |
| 27 | #include "mpeg4audio.h" | 28 | #include "mpeg4audio.h" |
| 28 | 29 | ||
| 29 | int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr) | 30 | int ff_adts_header_parse(GetBitContext *gbc, AACADTSHeaderInfo *hdr) |
| 30 | { | 31 | { |
| 31 | int size, rdb, ch, sr; | 32 | int size, rdb, ch, sr; |
| 32 | int aot, crc_abs; | 33 | int aot, crc_abs; |
| @@ -51,7 +52,7 @@ int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr) · 18 unmodified lines | |||
| 51 | skip_bits1(gbc); /* copyright_identification_bit */ | 52 | skip_bits1(gbc); /* copyright_identification_bit */ |
| 52 | skip_bits1(gbc); /* copyright_identification_start */ | 53 | skip_bits1(gbc); /* copyright_identification_start */ |
| 53 | size = get_bits(gbc, 13); /* aac_frame_length */ | 54 | size = get_bits(gbc, 13); /* aac_frame_length */ |
| 54 | if (size < AAC_ADTS_HEADER_SIZE) | 55 | if (size < AV_AAC_ADTS_HEADER_SIZE) |
| 55 | return AAC_AC3_PARSE_ERROR_FRAME_SIZE; | 56 | return AAC_AC3_PARSE_ERROR_FRAME_SIZE; |
| 56 | 57 | ||
| 57 | skip_bits(gbc, 11); /* adts_buffer_fullness */ | 58 | skip_bits(gbc, 11); /* adts_buffer_fullness */ |
| @@ -20,14 +20,11 @@ · 19 unmodified lines | |||
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #ifndef AVCODEC_AACADTSDEC_H | 23 | #ifndef AVCODEC_ADTS_HEADER_H |
| 24 | #define AVCODEC_AACADTSDEC_H | 24 | #define AVCODEC_ADTS_HEADER_H |
| 25 | 25 | ||
| 26 | #include <stdint.h> | ||
| 27 | #include "get_bits.h" | 26 | #include "get_bits.h" |
| 28 | 27 | ||
| 29 | #define AAC_ADTS_HEADER_SIZE 7 | ||
| 30 | |||
| 31 | typedef struct AACADTSHeaderInfo { | 28 | typedef struct AACADTSHeaderInfo { |
| 32 | uint32_t sample_rate; | 29 | uint32_t sample_rate; |
| 33 | uint32_t samples; | 30 | uint32_t samples; |
| @@ -40,7 +37,6 @@ typedef struct AACADTSHeaderInfo { · 6 unmodified lines | |||
| 40 | } AACADTSHeaderInfo; | 37 | } AACADTSHeaderInfo; |
| 41 | 38 | ||
| 42 | /** | 39 | /** |
| 43 | * Parse AAC frame header. | ||
| 44 | * Parse the ADTS frame header to the end of the variable header, which is | 40 | * Parse the ADTS frame header to the end of the variable header, which is |
| 45 | * the first 54 bits. | 41 | * the first 54 bits. |
| 46 | * @param[in] gbc BitContext containing the first 54 bits of the frame. | 42 | * @param[in] gbc BitContext containing the first 54 bits of the frame. |
| @@ -49,6 +45,6 @@ typedef struct AACADTSHeaderInfo { · 2 unmodified lines | |||
| 49 | * -2 if the version element is invalid, -3 if the sample rate | 45 | * -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. | 46 | * element is invalid, or -4 if the bit rate element is invalid. |
| 51 | */ | 47 | */ |
| 52 | int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr); | 48 | int ff_adts_header_parse(GetBitContext *gbc, AACADTSHeaderInfo *hdr); |
| 53 | 49 | ||
| 54 | #endif /* AVCODEC_AACADTSDEC_H */ | 50 | #endif /* AVCODEC_ADTS_HEADER_H */ |
| @@ -0,0 +1,44 @@ | |||
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU Lesser General Public | ||
| 6 | * License as published by the Free Software Foundation; either | ||
| 7 | * version 2.1 of the License, or (at your option) any later version. | ||
| 8 | * | ||
| 9 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 12 | * Lesser General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU Lesser General Public | ||
| 15 | * License along with FFmpeg; if not, write to the Free Software | ||
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include "config.h" | ||
| 20 | |||
| 21 | #include <stddef.h> | ||
| 22 | #include <stdint.h> | ||
| 23 | |||
| 24 | #include "adts_header.h" | ||
| 25 | #include "adts_parser.h" | ||
| 26 | |||
| 27 | int av_adts_header_parse(const uint8_t *buf, uint32_t *samples, uint8_t *frames) | ||
| 28 | { | ||
| 29 | #if CONFIG_ADTS_HEADER | ||
| 30 | GetBitContext gb; | ||
| 31 | AACADTSHeaderInfo hdr; | ||
| 32 | int err = init_get_bits8(&gb, buf, AV_AAC_ADTS_HEADER_SIZE); | ||
| 33 | if (err < 0) | ||
| 34 | return err; | ||
| 35 | err = ff_adts_header_parse(&gb, &hdr); | ||
| 36 | if (err < 0) | ||
| 37 | return err; | ||
| 38 | *samples = hdr.samples; | ||
| 39 | *frames = hdr.num_aac_frames; | ||
| 40 | return 0; | ||
| 41 | #else | ||
| 42 | return AVERROR(ENOSYS); | ||
| 43 | #endif | ||
| 44 | } | ||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU Lesser General Public | ||
| 6 | * License as published by the Free Software Foundation; either | ||
| 7 | * version 2.1 of the License, or (at your option) any later version. | ||
| 8 | * | ||
| 9 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 12 | * Lesser General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU Lesser General Public | ||
| 15 | * License along with FFmpeg; if not, write to the Free Software | ||
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | |||
| 19 | #ifndef AVCODEC_ADTS_PARSER_H | ||
| 20 | #define AVCODEC_ADTS_PARSER_H | ||
| 21 | |||
| 22 | #include <stddef.h> | ||
| 23 | #include <stdint.h> | ||
| 24 | |||
| 25 | #define AV_AAC_ADTS_HEADER_SIZE 7 | ||
| 26 | |||
| 27 | /** | ||
| 28 | * Extract the number of samples and frames from AAC data. | ||
| 29 | * @param[in] buf pointer to AAC data buffer | ||
| 30 | * @param[out] samples Pointer to where number of samples is written | ||
| 31 | * @param[out] frames Pointer to where number of frames is written | ||
| 32 | * @return Returns 0 on success, error code on failure. | ||
| 33 | */ | ||
| 34 | int av_adts_header_parse(const uint8_t *buf, uint32_t *samples, | ||
| 35 | uint8_t *frames); | ||
| 36 | |||
| 37 | #endif /* AVCODEC_ADTS_PARSER_H */ | ||
| @@ -25,18 +25,22 @@ · 24 unmodified lines | |||
| 25 | * @author Anssi Hannula | 25 | * @author Anssi Hannula |
| 26 | */ | 26 | */ |
| 27 | 27 | ||
| 28 | #include "libavutil/bswap.h" | ||
| 29 | |||
| 30 | #include "libavcodec/ac3.h" | ||
| 31 | #include "libavcodec/adts_parser.h" | ||
| 32 | |||
| 28 | #include "avformat.h" | 33 | #include "avformat.h" |
| 29 | #include "spdif.h" | 34 | #include "spdif.h" |
| 30 | #include "libavcodec/ac3.h" | ||
| 31 | #include "libavcodec/aacadtsdec.h" | ||
| 32 | 35 | ||
| 33 | static int spdif_get_offset_and_codec(AVFormatContext *s, | 36 | static int spdif_get_offset_and_codec(AVFormatContext *s, |
| 34 | enum IEC61937DataType data_type, | 37 | enum IEC61937DataType data_type, |
| 35 | const char *buf, int *offset, | 38 | const char *buf, int *offset, |
| 36 | enum AVCodecID *codec) | 39 | enum AVCodecID *codec) |
| 37 | { | 40 | { |
| 38 | AACADTSHeaderInfo aac_hdr; | 41 | uint32_t samples; |
| 39 | GetBitContext gbc; | 42 | uint8_t frames; |
| 43 | int ret; | ||
| 40 | 44 | ||
| 41 | switch (data_type & 0xff) { | 45 | switch (data_type & 0xff) { |
| 42 | case IEC61937_AC3: | 46 | case IEC61937_AC3: |
| @@ -56,13 +60,13 @@ static int spdif_get_offset_and_codec(AVFormatContext *s, · 13 unmodified lines | |||
| 56 | *codec = AV_CODEC_ID_MP3; | 60 | *codec = AV_CODEC_ID_MP3; |
| 57 | break; | 61 | break; |
| 58 | case IEC61937_MPEG2_AAC: | 62 | case IEC61937_MPEG2_AAC: |
| 59 | init_get_bits(&gbc, buf, AAC_ADTS_HEADER_SIZE * 8); | 63 | ret = av_adts_header_parse(buf, &samples, &frames); |
| 60 | if (avpriv_aac_parse_header(&gbc, &aac_hdr) < 0) { | 64 | if (ret < 0) { |
| 61 | if (s) /* be silent during a probe */ | 65 | if (s) /* be silent during a probe */ |
| 62 | av_log(s, AV_LOG_ERROR, "Invalid AAC packet in IEC 61937\n"); | 66 | av_log(s, AV_LOG_ERROR, "Invalid AAC packet in IEC 61937\n"); |
| 63 | return AVERROR_INVALIDDATA; | 67 | return ret; |
| 64 | } | 68 | } |
| 65 | *offset = aac_hdr.samples << 2; | 69 | *offset = samples << 2; |
| 66 | *codec = AV_CODEC_ID_AAC; | 70 | *codec = AV_CODEC_ID_AAC; |
| 67 | break; | 71 | break; |
| 68 | case IEC61937_MPEG2_LAYER1_LSF: | 72 | case IEC61937_MPEG2_LAYER1_LSF: |
| @@ -100,7 +104,7 @@ static int spdif_get_offset_and_codec(AVFormatContext *s, · 31 unmodified lines | |||
| 100 | } | 104 | } |
| 101 | 105 | ||
| 102 | /* Largest offset between bursts we currently handle, i.e. AAC with | 106 | /* Largest offset between bursts we currently handle, i.e. AAC with |
| 103 | aac_hdr.samples = 4096 */ | 107 | samples = 4096 */ |
| 104 | #define SPDIF_MAX_OFFSET 16384 | 108 | #define SPDIF_MAX_OFFSET 16384 |
| 105 | 109 | ||
| 106 | static int spdif_probe(AVProbeData *p) | 110 | static int spdif_probe(AVProbeData *p) |
| @@ -132,7 +136,7 @@ int ff_spdif_probe(const uint8_t *p_buf, int buf_size, enum AVCodecID *codec) · 25 unmodified lines | |||
| 132 | } else | 136 | } else |
| 133 | consecutive_codes = 0; | 137 | consecutive_codes = 0; |
| 134 | 138 | ||
| 135 | if (buf + 4 + AAC_ADTS_HEADER_SIZE > p_buf + buf_size) | 139 | if (buf + 4 + AV_AAC_ADTS_HEADER_SIZE > p_buf + buf_size) |
| 136 | break; | 140 | break; |
| 137 | 141 | ||
| 138 | /* continue probing to find more sync codes */ | 142 | /* continue probing to find more sync codes */ |
| @@ -50,9 +50,9 @@ · 49 unmodified lines | |||
| 50 | #include "avio_internal.h" | 50 | #include "avio_internal.h" |
| 51 | #include "spdif.h" | 51 | #include "spdif.h" |
| 52 | #include "libavcodec/ac3.h" | 52 | #include "libavcodec/ac3.h" |
| 53 | #include "libavcodec/adts_parser.h" | ||
| 53 | #include "libavcodec/dca.h" | 54 | #include "libavcodec/dca.h" |
| 54 | #include "libavcodec/dca_syncwords.h" | 55 | #include "libavcodec/dca_syncwords.h" |
| 55 | #include "libavcodec/aacadtsdec.h" | ||
| 56 | #include "libavutil/opt.h" | 56 | #include "libavutil/opt.h" |
| 57 | 57 | ||
| 58 | typedef struct IEC61937Context { | 58 | typedef struct IEC61937Context { |
| @@ -349,19 +349,18 @@ static int spdif_header_mpeg(AVFormatContext *s, AVPacket *pkt) · 290 unmodified lines | |||
| 349 | static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt) | 349 | static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt) |
| 350 | { | 350 | { |
| 351 | IEC61937Context *ctx = s->priv_data; | 351 | IEC61937Context *ctx = s->priv_data; |
| 352 | AACADTSHeaderInfo hdr; | 352 | uint32_t samples; |
| 353 | GetBitContext gbc; | 353 | uint8_t frames; |
| 354 | int ret; | 354 | int ret; |
| 355 | 355 | ||
| 356 | init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8); | 356 | ret = av_adts_header_parse(pkt->data, &samples, &frames); |
| 357 | ret = avpriv_aac_parse_header(&gbc, &hdr); | ||
| 358 | if (ret < 0) { | 357 | if (ret < 0) { |
| 359 | av_log(s, AV_LOG_ERROR, "Wrong AAC file format\n"); | 358 | av_log(s, AV_LOG_ERROR, "Wrong AAC file format\n"); |
| 360 | return AVERROR_INVALIDDATA; | 359 | return ret; |
| 361 | } | 360 | } |
| 362 | 361 | ||
| 363 | ctx->pkt_offset = hdr.samples << 2; | 362 | ctx->pkt_offset = samples << 2; |
| 364 | switch (hdr.num_aac_frames) { | 363 | switch (frames) { |
| 365 | case 1: | 364 | case 1: |
| 366 | ctx->data_type = IEC61937_MPEG2_AAC; | 365 | ctx->data_type = IEC61937_MPEG2_AAC; |
| 367 | break; | 366 | break; |
| @@ -373,7 +372,7 @@ static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt) · 5 unmodified lines | |||
| 373 | break; | 372 | break; |
| 374 | default: | 373 | default: |
| 375 | av_log(s, AV_LOG_ERROR, | 374 | av_log(s, AV_LOG_ERROR, |
| 376 | "%"PRIu32" samples in AAC frame not supported\n", hdr.samples); | 375 | "%"PRIu32" samples in AAC frame not supported\n", samples); |
| 377 | return AVERROR(EINVAL); | 376 | return AVERROR(EINVAL); |
| 378 | } | 377 | } |
| 379 | //TODO Data type dependent info (LC profile/SBR) | 378 | //TODO Data type dependent info (LC profile/SBR) |