av1.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * AV1 helper functions for muxers
  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. #ifndef AVFORMAT_AV1_H
  21. #define AVFORMAT_AV1_H
  22. #include <stdint.h>
  23. #include "avio.h"
  24. typedef struct AV1SequenceParameters {
  25. uint8_t profile;
  26. uint8_t level;
  27. uint8_t tier;
  28. uint8_t bitdepth;
  29. uint8_t monochrome;
  30. uint8_t chroma_subsampling_x;
  31. uint8_t chroma_subsampling_y;
  32. uint8_t chroma_sample_position;
  33. uint8_t color_description_present_flag;
  34. uint8_t color_primaries;
  35. uint8_t transfer_characteristics;
  36. uint8_t matrix_coefficients;
  37. uint8_t color_range;
  38. } AV1SequenceParameters;
  39. /**
  40. * Filter out AV1 OBUs not meant to be present in ISOBMFF sample data and write
  41. * the resulting bitstream to the provided AVIOContext.
  42. *
  43. * @param pb pointer to the AVIOContext where the filtered bitstream shall be
  44. * written
  45. * @param buf input data buffer
  46. * @param size size of the input data buffer
  47. *
  48. * @return the amount of bytes written in case of success, a negative AVERROR
  49. * code in case of failure
  50. */
  51. int ff_av1_filter_obus(AVIOContext *pb, const uint8_t *buf, int size);
  52. /**
  53. * Filter out AV1 OBUs not meant to be present in ISOBMFF sample data and return
  54. * the result in a data buffer, avoiding allocations and copies if possible.
  55. *
  56. * @param in input data buffer
  57. * @param out pointer to pointer for the returned buffer. In case of success,
  58. * it is independently allocated if and only if `*out` differs from in.
  59. * @param size size of the input data buffer. The size of the resulting output
  60. * data buffer will be written here
  61. * @param offset offset of the returned data inside `*out`: It runs from
  62. * `*out + offset` (inclusive) to `*out + offset + size`
  63. * (exclusive); is zero if `*out` is independently allocated.
  64. *
  65. * @return 0 in case of success, a negative AVERROR code in case of failure.
  66. * On failure, *out and *size are unchanged
  67. * @note *out will be treated as unintialized on input and will not be freed.
  68. */
  69. int ff_av1_filter_obus_buf(const uint8_t *in, uint8_t **out,
  70. int *size, int *offset);
  71. /**
  72. * Parses a Sequence Header from the the provided buffer.
  73. *
  74. * @param seq pointer to the AV1SequenceParameters where the parsed values will
  75. * be written
  76. * @param buf input data buffer
  77. * @param size size in bytes of the input data buffer
  78. *
  79. * @return >= 0 in case of success, a negative AVERROR code in case of failure
  80. */
  81. int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int size);
  82. /**
  83. * Writes AV1 extradata (Sequence Header and Metadata OBUs) to the provided
  84. * AVIOContext.
  85. *
  86. * @param pb pointer to the AVIOContext where the av1C box shall be written
  87. * @param buf input data buffer
  88. * @param size size in bytes of the input data buffer
  89. *
  90. * @return >= 0 in case of success, a negative AVERROR code in case of failure
  91. */
  92. int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size);
  93. #endif /* AVFORMAT_AV1_H */