You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
3.5KB

  1. /*
  2. * Copyright (C) 2007 Marco Gerards <marco@gnu.org>
  3. * Copyright (C) 2009 David Conrad
  4. * Copyright (C) 2011 Jordi Ortiz
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef AVCODEC_DIRAC_H
  23. #define AVCODEC_DIRAC_H
  24. /**
  25. * @file
  26. * Interface to Dirac Decoder/Encoder
  27. * @author Marco Gerards <marco@gnu.org>
  28. * @author David Conrad
  29. * @author Jordi Ortiz
  30. */
  31. #include "avcodec.h"
  32. /**
  33. * Parse code values:
  34. *
  35. * Dirac Specification ->
  36. * 9.6.1 Table 9.1
  37. *
  38. * VC-2 Specification ->
  39. * 10.4.1 Table 10.1
  40. */
  41. enum DiracParseCodes {
  42. DIRAC_PCODE_SEQ_HEADER = 0x00,
  43. DIRAC_PCODE_END_SEQ = 0x10,
  44. DIRAC_PCODE_AUX = 0x20,
  45. DIRAC_PCODE_PAD = 0x30,
  46. DIRAC_PCODE_PICTURE_CODED = 0x08,
  47. DIRAC_PCODE_PICTURE_RAW = 0x48,
  48. DIRAC_PCODE_PICTURE_LOW_DEL = 0xC8,
  49. DIRAC_PCODE_PICTURE_HQ = 0xE8,
  50. DIRAC_PCODE_INTER_NOREF_CO1 = 0x0A,
  51. DIRAC_PCODE_INTER_NOREF_CO2 = 0x09,
  52. DIRAC_PCODE_INTER_REF_CO1 = 0x0D,
  53. DIRAC_PCODE_INTER_REF_CO2 = 0x0E,
  54. DIRAC_PCODE_INTRA_REF_CO = 0x0C,
  55. DIRAC_PCODE_INTRA_REF_RAW = 0x4C,
  56. DIRAC_PCODE_INTRA_REF_PICT = 0xCC,
  57. DIRAC_PCODE_MAGIC = 0x42424344,
  58. };
  59. typedef struct DiracVersionInfo {
  60. int major;
  61. int minor;
  62. } DiracVersionInfo;
  63. typedef struct AVDiracSeqHeader {
  64. unsigned width;
  65. unsigned height;
  66. uint8_t chroma_format; ///< 0: 444 1: 422 2: 420
  67. uint8_t interlaced;
  68. uint8_t top_field_first;
  69. uint8_t frame_rate_index; ///< index into dirac_frame_rate[]
  70. uint8_t aspect_ratio_index; ///< index into dirac_aspect_ratio[]
  71. uint16_t clean_width;
  72. uint16_t clean_height;
  73. uint16_t clean_left_offset;
  74. uint16_t clean_right_offset;
  75. uint8_t pixel_range_index; ///< index into dirac_pixel_range_presets[]
  76. uint8_t color_spec_index; ///< index into dirac_color_spec_presets[]
  77. int profile;
  78. int level;
  79. AVRational framerate;
  80. AVRational sample_aspect_ratio;
  81. enum AVPixelFormat pix_fmt;
  82. enum AVColorRange color_range;
  83. enum AVColorPrimaries color_primaries;
  84. enum AVColorTransferCharacteristic color_trc;
  85. enum AVColorSpace colorspace;
  86. DiracVersionInfo version;
  87. int bit_depth;
  88. } AVDiracSeqHeader;
  89. /**
  90. * Parse a Dirac sequence header.
  91. *
  92. * @param dsh this function will allocate and fill an AVDiracSeqHeader struct
  93. * and write it into this pointer. The caller must free it with
  94. * av_free().
  95. * @param buf the data buffer
  96. * @param buf_size the size of the data buffer in bytes
  97. * @param log_ctx if non-NULL, this function will log errors here
  98. * @return 0 on success, a negative AVERROR code on failure
  99. */
  100. int av_dirac_parse_sequence_header(AVDiracSeqHeader **dsh,
  101. const uint8_t *buf, size_t buf_size,
  102. void *log_ctx);
  103. #endif /* AVCODEC_DIRAC_H */