flac_parse.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. * @file
  23. * FLAC (Free Lossless Audio Codec) decoder/parser common functions
  24. */
  25. #ifndef AVCODEC_FLAC_PARSE_H
  26. #define AVCODEC_FLAC_PARSE_H
  27. #include "avcodec.h"
  28. #include "get_bits.h"
  29. typedef struct FLACStreaminfo {
  30. int samplerate; /**< sample rate */
  31. int channels; /**< number of channels */
  32. int bps; /**< bits-per-sample */
  33. int max_blocksize; /**< maximum block size, in samples */
  34. int max_framesize; /**< maximum frame size, in bytes */
  35. int64_t samples; /**< total number of samples */
  36. } FLACStreaminfo;
  37. typedef struct FLACFrameInfo {
  38. int samplerate; /**< sample rate */
  39. int channels; /**< number of channels */
  40. int bps; /**< bits-per-sample */
  41. int blocksize; /**< block size of the frame */
  42. int ch_mode; /**< channel decorrelation mode */
  43. int64_t frame_or_sample_num; /**< frame number or sample number */
  44. int is_var_size; /**< specifies if the stream uses variable
  45. block sizes or a fixed block size;
  46. also determines the meaning of
  47. frame_or_sample_num */
  48. } FLACFrameInfo;
  49. /**
  50. * Parse the Streaminfo metadata block
  51. * @param[out] avctx codec context to set basic stream parameters
  52. * @param[out] s where parsed information is stored
  53. * @param[in] buffer pointer to start of 34-byte streaminfo data
  54. *
  55. * @return negative error code on failure or >= 0 on success
  56. */
  57. int ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
  58. const uint8_t *buffer);
  59. /**
  60. * Validate the FLAC extradata.
  61. * @param[in] avctx codec context containing the extradata.
  62. * @param[out] format extradata format.
  63. * @param[out] streaminfo_start pointer to start of 34-byte STREAMINFO data.
  64. * @return 1 if valid, 0 if not valid.
  65. */
  66. int ff_flac_is_extradata_valid(AVCodecContext *avctx,
  67. uint8_t **streaminfo_start);
  68. /**
  69. * Validate and decode a frame header.
  70. * @param logctx context for logging
  71. * @param gb GetBitContext from which to read frame header
  72. * @param[out] fi frame information
  73. * @param log_level_offset log level offset. can be used to silence error messages.
  74. * @return non-zero on error, 0 if ok
  75. */
  76. int ff_flac_decode_frame_header(void *logctx, GetBitContext *gb,
  77. FLACFrameInfo *fi, int log_level_offset);
  78. void ff_flac_set_channel_layout(AVCodecContext *avctx, int channels);
  79. #endif /* AVCODEC_FLAC_PARSE_H */