vp9shared.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * VP9 compatible video decoder
  3. *
  4. * Copyright (C) 2013 Ronald S. Bultje <rsbultje gmail com>
  5. * Copyright (C) 2013 Clément Bœsch <u pkh me>
  6. *
  7. * This file is part of FFmpeg.
  8. *
  9. * FFmpeg is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * FFmpeg is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with FFmpeg; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. #ifndef AVCODEC_VP9SHARED_H
  24. #define AVCODEC_VP9SHARED_H
  25. #include <stddef.h>
  26. #include <stdint.h>
  27. #include "vp9.h"
  28. #include "thread.h"
  29. #include "vp56.h"
  30. enum BlockPartition {
  31. PARTITION_NONE, // [ ] <-.
  32. PARTITION_H, // [-] |
  33. PARTITION_V, // [|] |
  34. PARTITION_SPLIT, // [+] --'
  35. };
  36. enum InterPredMode {
  37. NEARESTMV = 10,
  38. NEARMV = 11,
  39. ZEROMV = 12,
  40. NEWMV = 13,
  41. };
  42. enum CompPredMode {
  43. PRED_SINGLEREF,
  44. PRED_COMPREF,
  45. PRED_SWITCHABLE,
  46. };
  47. typedef struct VP9mvrefPair {
  48. VP56mv mv[2];
  49. int8_t ref[2];
  50. } VP9mvrefPair;
  51. typedef struct VP9Frame {
  52. ThreadFrame tf;
  53. AVBufferRef *extradata;
  54. uint8_t *segmentation_map;
  55. VP9mvrefPair *mv;
  56. int uses_2pass;
  57. AVBufferRef *hwaccel_priv_buf;
  58. void *hwaccel_picture_private;
  59. } VP9Frame;
  60. enum BlockLevel {
  61. BL_64X64,
  62. BL_32X32,
  63. BL_16X16,
  64. BL_8X8,
  65. };
  66. enum BlockSize {
  67. BS_64x64,
  68. BS_64x32,
  69. BS_32x64,
  70. BS_32x32,
  71. BS_32x16,
  72. BS_16x32,
  73. BS_16x16,
  74. BS_16x8,
  75. BS_8x16,
  76. BS_8x8,
  77. BS_8x4,
  78. BS_4x8,
  79. BS_4x4,
  80. N_BS_SIZES,
  81. };
  82. typedef struct VP9BitstreamHeader {
  83. // bitstream header
  84. uint8_t profile;
  85. uint8_t bpp;
  86. uint8_t keyframe;
  87. uint8_t invisible;
  88. uint8_t errorres;
  89. uint8_t intraonly;
  90. uint8_t resetctx;
  91. uint8_t refreshrefmask;
  92. uint8_t highprecisionmvs;
  93. enum FilterMode filtermode;
  94. uint8_t allowcompinter;
  95. uint8_t refreshctx;
  96. uint8_t parallelmode;
  97. uint8_t framectxid;
  98. uint8_t use_last_frame_mvs;
  99. uint8_t refidx[3];
  100. uint8_t signbias[3];
  101. uint8_t fixcompref;
  102. uint8_t varcompref[2];
  103. struct {
  104. uint8_t level;
  105. int8_t sharpness;
  106. } filter;
  107. struct {
  108. uint8_t enabled;
  109. uint8_t updated;
  110. int8_t mode[2];
  111. int8_t ref[4];
  112. } lf_delta;
  113. uint8_t yac_qi;
  114. int8_t ydc_qdelta, uvdc_qdelta, uvac_qdelta;
  115. uint8_t lossless;
  116. #define MAX_SEGMENT 8
  117. struct {
  118. uint8_t enabled;
  119. uint8_t temporal;
  120. uint8_t absolute_vals;
  121. uint8_t update_map;
  122. uint8_t prob[7];
  123. uint8_t pred_prob[3];
  124. struct {
  125. uint8_t q_enabled;
  126. uint8_t lf_enabled;
  127. uint8_t ref_enabled;
  128. uint8_t skip_enabled;
  129. uint8_t ref_val;
  130. int16_t q_val;
  131. int8_t lf_val;
  132. int16_t qmul[2][2];
  133. uint8_t lflvl[4][2];
  134. } feat[MAX_SEGMENT];
  135. } segmentation;
  136. enum TxfmMode txfmmode;
  137. enum CompPredMode comppredmode;
  138. struct {
  139. unsigned log2_tile_cols, log2_tile_rows;
  140. unsigned tile_cols, tile_rows;
  141. } tiling;
  142. int uncompressed_header_size;
  143. int compressed_header_size;
  144. } VP9BitstreamHeader;
  145. typedef struct VP9SharedContext {
  146. VP9BitstreamHeader h;
  147. ThreadFrame refs[8];
  148. #define CUR_FRAME 0
  149. #define REF_FRAME_MVPAIR 1
  150. #define REF_FRAME_SEGMAP 2
  151. VP9Frame frames[3];
  152. } VP9SharedContext;
  153. #endif /* AVCODEC_VP9SHARED_H */