hevc.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (c) 2014 Tim Walker <tdskywalker@gmail.com>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /**
  21. * @file
  22. * internal header for HEVC (de)muxer utilities
  23. */
  24. #ifndef AVFORMAT_HEVC_H
  25. #define AVFORMAT_HEVC_H
  26. #include <stdint.h>
  27. #include "avio.h"
  28. /**
  29. * Writes Annex B formatted HEVC NAL units to the provided AVIOContext.
  30. *
  31. * The NAL units are converted to an MP4-compatible format (start code prefixes
  32. * are replaced by 4-byte size fields, as per ISO/IEC 14496-15).
  33. *
  34. * If filter_ps is non-zero, any HEVC parameter sets found in the input will be
  35. * discarded, and *ps_count will be set to the number of discarded PS NAL units.
  36. *
  37. * @param pb address of the AVIOContext where the data shall be written
  38. * @param buf_in address of the buffer holding the input data
  39. * @param size size (in bytes) of the input buffer
  40. * @param filter_ps whether to write parameter set NAL units to the output (0)
  41. * or to discard them (non-zero)
  42. * @param ps_count address of the variable where the number of discarded
  43. * parameter set NAL units shall be written, may be NULL
  44. * @return the amount (in bytes) of data written in case of success, a negative
  45. * value corresponding to an AVERROR code in case of failure
  46. */
  47. int ff_hevc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in,
  48. int size, int filter_ps, int *ps_count);
  49. /**
  50. * Writes Annex B formatted HEVC NAL units to a data buffer.
  51. *
  52. * The NAL units are converted to an MP4-compatible format (start code prefixes
  53. * are replaced by 4-byte size fields, as per ISO/IEC 14496-15).
  54. *
  55. * If filter_ps is non-zero, any HEVC parameter sets found in the input will be
  56. * discarded, and *ps_count will be set to the number of discarded PS NAL units.
  57. *
  58. * On success, *size holds the size (in bytes) of the output data buffer.
  59. *
  60. * @param buf_in address of the buffer holding the input data
  61. * @param size address of the variable holding the size (in bytes) of the input
  62. * buffer (on input) and of the output buffer (on success)
  63. * @param buf_out on success, address of the variable holding the address of
  64. * the output buffer
  65. * @param filter_ps whether to write parameter set NAL units to the output (0)
  66. * or to discard them (non-zero)
  67. * @param ps_count address of the variable where the number of discarded
  68. * parameter set NAL units shall be written, may be NULL
  69. * @return 0 in case of success, a negative value corresponding to an AVERROR
  70. * code in case of failure
  71. * @note *buf_out will be treated as uninitialized on input and won't be freed.
  72. */
  73. int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out,
  74. int *size, int filter_ps, int *ps_count);
  75. /**
  76. * Writes HEVC extradata (parameter sets, declarative SEI NAL units) to the
  77. * provided AVIOContext.
  78. *
  79. * If the extradata is Annex B format, it gets converted to hvcC format before
  80. * writing.
  81. *
  82. * @param pb address of the AVIOContext where the hvcC shall be written
  83. * @param data address of the buffer holding the data needed to write the hvcC
  84. * @param size size (in bytes) of the data buffer
  85. * @param ps_array_completeness whether all parameter sets are in the hvcC (1)
  86. * or there may be additional parameter sets in the bitstream (0)
  87. * @return >=0 in case of success, a negative value corresponding to an AVERROR
  88. * code in case of failure
  89. */
  90. int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data,
  91. int size, int ps_array_completeness);
  92. #endif /* AVFORMAT_HEVC_H */