vp9_scan.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef VP9_COMMON_VP9_SCAN_H_
  11. #define VP9_COMMON_VP9_SCAN_H_
  12. #include "vpx/vpx_integer.h"
  13. #include "vpx_ports/mem.h"
  14. #include "vp9/common/vp9_enums.h"
  15. #include "vp9/common/vp9_blockd.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #define MAX_NEIGHBORS 2
  20. typedef struct {
  21. const int16_t *scan;
  22. const int16_t *iscan;
  23. const int16_t *neighbors;
  24. } scan_order;
  25. extern const scan_order vp9_default_scan_orders[TX_SIZES];
  26. extern const scan_order vp9_scan_orders[TX_SIZES][TX_TYPES];
  27. static INLINE int get_coef_context(const int16_t *neighbors,
  28. const uint8_t *token_cache, int c) {
  29. return (1 + token_cache[neighbors[MAX_NEIGHBORS * c + 0]] +
  30. token_cache[neighbors[MAX_NEIGHBORS * c + 1]]) >> 1;
  31. }
  32. static INLINE const scan_order *get_scan(const MACROBLOCKD *xd, TX_SIZE tx_size,
  33. PLANE_TYPE type, int block_idx) {
  34. const MODE_INFO *const mi = xd->mi[0];
  35. if (is_inter_block(mi) || type != PLANE_TYPE_Y || xd->lossless) {
  36. return &vp9_default_scan_orders[tx_size];
  37. } else {
  38. const PREDICTION_MODE mode = get_y_mode(mi, block_idx);
  39. return &vp9_scan_orders[tx_size][intra_mode_to_tx_type_lookup[mode]];
  40. }
  41. }
  42. #ifdef __cplusplus
  43. } // extern "C"
  44. #endif
  45. #endif // VP9_COMMON_VP9_SCAN_H_