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.

99 lines
2.9KB

  1. /*
  2. * Vidvox Hap
  3. * Copyright (C) 2015 Vittorio Giovara <vittorio.giovara@gmail.com>
  4. * Copyright (C) 2015 Tom Butterworth <bangnoise@gmail.com>
  5. *
  6. * This file is part of Libav.
  7. *
  8. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef AVCODEC_HAP_H
  23. #define AVCODEC_HAP_H
  24. #include <stdint.h>
  25. #include "libavutil/opt.h"
  26. #include "bytestream.h"
  27. #include "texturedsp.h"
  28. enum HapTextureFormat {
  29. HAP_FMT_RGBDXT1 = 0x0B,
  30. HAP_FMT_RGBADXT5 = 0x0E,
  31. HAP_FMT_YCOCGDXT5 = 0x0F,
  32. };
  33. enum HapCompressor {
  34. HAP_COMP_NONE = 0xA0,
  35. HAP_COMP_SNAPPY = 0xB0,
  36. HAP_COMP_COMPLEX = 0xC0,
  37. };
  38. enum HapSectionType {
  39. HAP_ST_DECODE_INSTRUCTIONS = 0x01,
  40. HAP_ST_COMPRESSOR_TABLE = 0x02,
  41. HAP_ST_SIZE_TABLE = 0x03,
  42. HAP_ST_OFFSET_TABLE = 0x04,
  43. };
  44. typedef struct HapChunk {
  45. enum HapCompressor compressor;
  46. int compressed_offset;
  47. size_t compressed_size;
  48. int uncompressed_offset;
  49. size_t uncompressed_size;
  50. } HapChunk;
  51. typedef struct HapContext {
  52. AVClass *class;
  53. TextureDSPContext dxtc;
  54. GetByteContext gbc;
  55. enum HapTextureFormat opt_tex_fmt; /* Texture type (encoder only) */
  56. int opt_chunk_count; /* User-requested chunk count (encoder only) */
  57. int chunk_count;
  58. HapChunk *chunks;
  59. int *chunk_results; /* Results from threaded operations */
  60. int tex_rat; /* Compression ratio */
  61. const uint8_t *tex_data; /* Compressed texture */
  62. uint8_t *tex_buf; /* Buffer for compressed texture */
  63. size_t tex_size; /* Size of the compressed texture */
  64. size_t max_snappy; /* Maximum compressed size for snappy buffer */
  65. int slice_count; /* Number of slices for threaded operations */
  66. /* Pointer to the selected compress or decompress function */
  67. int (*tex_fun)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
  68. } HapContext;
  69. /*
  70. * Set the number of chunks in the frame. Returns 0 on success or an error if:
  71. * - first_in_frame is 0 and the number of chunks has changed
  72. * - any other error occurs
  73. */
  74. int ff_hap_set_chunk_count(HapContext *ctx, int count, int first_in_frame);
  75. /*
  76. * Free resources associated with the context
  77. */
  78. av_cold void ff_hap_free_context(HapContext *ctx);
  79. #endif /* AVCODEC_HAP_H */