tor-browser

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

flac_parse.h (3752B)


      1 /*
      2 * FLAC (Free Lossless Audio Codec) decoder/parser common functions
      3 * Copyright (c) 2008 Justin Ruggles
      4 *
      5 * This file is part of FFmpeg.
      6 *
      7 * FFmpeg is free software; you can redistribute it and/or
      8 * modify it under the terms of the GNU Lesser General Public
      9 * License as published by the Free Software Foundation; either
     10 * version 2.1 of the License, or (at your option) any later version.
     11 *
     12 * FFmpeg is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15 * Lesser General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU Lesser General Public
     18 * License along with FFmpeg; if not, write to the Free Software
     19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
     20 */
     21 
     22 /**
     23 * @file
     24 * FLAC (Free Lossless Audio Codec) decoder/parser common functions
     25 */
     26 
     27 #ifndef AVCODEC_FLAC_PARSE_H
     28 #define AVCODEC_FLAC_PARSE_H
     29 
     30 #include "avcodec.h"
     31 #include "get_bits.h"
     32 
     33 typedef struct FLACStreaminfo {
     34    int samplerate;         /**< sample rate                             */
     35    int channels;           /**< number of channels                      */
     36    int bps;                /**< bits-per-sample                         */
     37    int max_blocksize;      /**< maximum block size, in samples          */
     38    int max_framesize;      /**< maximum frame size, in bytes            */
     39    int64_t samples;        /**< total number of samples                 */
     40 } FLACStreaminfo;
     41 
     42 typedef struct FLACFrameInfo {
     43    int samplerate;         /**< sample rate                             */
     44    int channels;           /**< number of channels                      */
     45    int bps;                /**< bits-per-sample                         */
     46    int blocksize;          /**< block size of the frame                 */
     47    int ch_mode;            /**< channel decorrelation mode              */
     48    int64_t frame_or_sample_num;    /**< frame number or sample number   */
     49    int is_var_size;                /**< specifies if the stream uses variable
     50                                         block sizes or a fixed block size;
     51                                         also determines the meaning of
     52                                         frame_or_sample_num             */
     53 } FLACFrameInfo;
     54 
     55 /**
     56 * Parse the Streaminfo metadata block
     57 * @param[out] avctx   codec context to set basic stream parameters
     58 * @param[out] s       where parsed information is stored
     59 * @param[in]  buffer  pointer to start of 34-byte streaminfo data
     60 *
     61 * @return negative error code on faiure or >= 0 on success
     62 */
     63 int ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
     64                              const uint8_t *buffer);
     65 
     66 /**
     67 * Validate the FLAC extradata.
     68 * @param[in]  avctx codec context containing the extradata.
     69 * @param[out] format extradata format.
     70 * @param[out] streaminfo_start pointer to start of 34-byte STREAMINFO data.
     71 * @return 1 if valid, 0 if not valid.
     72 */
     73 int ff_flac_is_extradata_valid(AVCodecContext *avctx,
     74                               uint8_t **streaminfo_start);
     75 
     76 /**
     77 * Validate and decode a frame header.
     78 * @param      logctx context for logging
     79 * @param      gb    GetBitContext from which to read frame header
     80 * @param[out] fi    frame information
     81 * @param      log_level_offset  log level offset. can be used to silence error messages.
     82 * @return non-zero on error, 0 if ok
     83 */
     84 int ff_flac_decode_frame_header(void *logctx, GetBitContext *gb,
     85                                FLACFrameInfo *fi, int log_level_offset);
     86 
     87 void ff_flac_set_channel_layout(AVCodecContext *avctx, int channels);
     88 
     89 #endif /* AVCODEC_FLAC_PARSE_H */