flac.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * FLAC (Free Lossless Audio Codec) decoder/demuxer 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 libavcodec/flac.h
  23. * FLAC (Free Lossless Audio Codec) decoder/demuxer common functions
  24. */
  25. #ifndef AVCODEC_FLAC_H
  26. #define AVCODEC_FLAC_H
  27. #include "avcodec.h"
  28. #define FLAC_STREAMINFO_SIZE 34
  29. enum {
  30. FLAC_METADATA_TYPE_STREAMINFO = 0,
  31. FLAC_METADATA_TYPE_PADDING,
  32. FLAC_METADATA_TYPE_APPLICATION,
  33. FLAC_METADATA_TYPE_SEEKTABLE,
  34. FLAC_METADATA_TYPE_VORBIS_COMMENT,
  35. FLAC_METADATA_TYPE_CUESHEET,
  36. FLAC_METADATA_TYPE_PICTURE,
  37. FLAC_METADATA_TYPE_INVALID = 127
  38. };
  39. enum FLACExtradataFormat {
  40. FLAC_EXTRADATA_FORMAT_STREAMINFO = 0,
  41. FLAC_EXTRADATA_FORMAT_FULL_HEADER = 1
  42. };
  43. /**
  44. * Data needed from the Streaminfo header for use by the raw FLAC demuxer
  45. * and/or the FLAC decoder.
  46. */
  47. #define FLACSTREAMINFO \
  48. int min_blocksize; /**< minimum block size, in samples */\
  49. int max_blocksize; /**< maximum block size, in samples */\
  50. int max_framesize; /**< maximum frame size, in bytes */\
  51. int samplerate; /**< sample rate */\
  52. int channels; /**< number of channels */\
  53. int bps; /**< bits-per-sample */\
  54. int64_t samples; /**< total number of samples */\
  55. typedef struct FLACStreaminfo {
  56. FLACSTREAMINFO
  57. } FLACStreaminfo;
  58. /**
  59. * Parse the Streaminfo metadata block
  60. * @param[out] avctx codec context to set basic stream parameters
  61. * @param[out] s where parsed information is stored
  62. * @param[in] buffer pointer to start of 34-byte streaminfo data
  63. */
  64. void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
  65. const uint8_t *buffer);
  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. enum FLACExtradataFormat *format,
  75. uint8_t **streaminfo_start);
  76. #endif /* AVCODEC_FLAC_H */