tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

adts_header.h (2919B)


      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_ADTS_HEADER_H
     24 #define AVCODEC_ADTS_HEADER_H
     25 
     26 #include "adts_parser.h"
     27 #include "defs.h"
     28 
     29 typedef enum {
     30    AAC_PARSE_ERROR_SYNC        = -0x1030c0a,
     31    AAC_PARSE_ERROR_SAMPLE_RATE = -0x3030c0a,
     32    AAC_PARSE_ERROR_FRAME_SIZE  = -0x4030c0a,
     33 } AACParseError;
     34 
     35 typedef struct AACADTSHeaderInfo {
     36    uint32_t sample_rate;
     37    uint32_t samples;
     38    uint32_t bit_rate;
     39    uint8_t  crc_absent;
     40    uint8_t  object_type;
     41    uint8_t  sampling_index;
     42    uint8_t  chan_config;
     43    uint8_t  num_aac_frames;
     44    uint32_t frame_length;
     45 } AACADTSHeaderInfo;
     46 
     47 struct GetBitContext;
     48 
     49 /**
     50 * Parse the ADTS frame header to the end of the variable header, which is
     51 * the first 54 bits.
     52 * @param[in]  gbc BitContext containing the first 54 bits of the frame.
     53 * @param[out] hdr Pointer to struct where header info is written.
     54 * @return the size in bytes of the header parsed on success and
     55 *         AAC_PARSE_ERROR_* values otherwise.
     56 */
     57 int ff_adts_header_parse(struct GetBitContext *gbc, AACADTSHeaderInfo *hdr);
     58 
     59 /**
     60 * Wrapper around ff_adts_header_parse() for users that don't already have
     61 * a suitable GetBitContext.
     62 */
     63 int ff_adts_header_parse_buf(const uint8_t buf[AV_AAC_ADTS_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE],
     64                             AACADTSHeaderInfo *hdr);
     65 
     66 /**
     67 * Parse the ADTS frame header contained in the buffer, which is
     68 * the first 54 bits.
     69 * @param[in]  buf  Pointer to buffer containing the first 54 bits of the frame.
     70 * @param[in]  size Size of buffer containing the first 54 bits of the frame.
     71 * @param[out] phdr Pointer to pointer to struct AACADTSHeaderInfo for which
     72 * memory is allocated and header info is written into it. After using the header
     73 * information, the allocated memory must be freed by using av_free.
     74 * @return 0 on success, AAC_PARSE_ERROR_* values on invalid input and
     75 *         ordinary AVERROR codes otherwise.
     76 */
     77 int avpriv_adts_header_parse(AACADTSHeaderInfo **phdr, const uint8_t *buf, size_t size);
     78 
     79 #endif /* AVCODEC_ADTS_HEADER_H */