cfl.h 2.83 KB
Newer Older
Luc Trudeau's avatar
Luc Trudeau committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
 *
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */

#ifndef AV1_COMMON_CFL_H_
#define AV1_COMMON_CFL_H_

15
#include "av1/common/blockd.h"
Luc Trudeau's avatar
Luc Trudeau committed
16

17 18 19
typedef void (*cfl_subsample_lbd_fn)(const uint8_t *input, int input_stride,
                                     int16_t *output_q3, int width, int height);

20 21 22 23
typedef void (*cfl_predict_lbd_fn)(const int16_t *pred_buf_q3, uint8_t *dst,
                                   int dst_stride, TX_SIZE tx_size,
                                   int alpha_q3);

24 25 26 27
typedef void (*cfl_predict_hbd_fn)(const int16_t *pred_buf_q3, uint16_t *dst,
                                   int dst_stride, TX_SIZE tx_size,
                                   int alpha_q3, int bd);

28 29 30
static INLINE int is_cfl_allowed(const MB_MODE_INFO *mbmi) {
  const BLOCK_SIZE bsize = mbmi->sb_type;
  assert(bsize < BLOCK_SIZES_ALL);
31
  return bsize <= CFL_MAX_BLOCK_SIZE;
32
}
33

Luc Trudeau's avatar
Luc Trudeau committed
34 35
static INLINE int get_scaled_luma_q0(int alpha_q3, int16_t pred_buf_q3) {
  int scaled_luma_q6 = alpha_q3 * pred_buf_q3;
36
  return ROUND_POWER_OF_TWO_SIGNED(scaled_luma_q6, 6);
37 38
}

39 40
static INLINE CFL_PRED_TYPE get_cfl_pred_type(PLANE_TYPE plane) {
  assert(plane > 0);
41
  return (CFL_PRED_TYPE)(plane - 1);
42 43
}

Luc Trudeau's avatar
Luc Trudeau committed
44
void cfl_predict_block(MACROBLOCKD *const xd, uint8_t *dst, int dst_stride,
45
                       TX_SIZE tx_size, int plane);
Luc Trudeau's avatar
Luc Trudeau committed
46

47 48 49 50
void cfl_store_block(MACROBLOCKD *const xd, BLOCK_SIZE bsize, TX_SIZE tx_size);

void cfl_store_tx(MACROBLOCKD *const xd, int row, int col, TX_SIZE tx_size,
                  BLOCK_SIZE bsize);
51 52 53 54 55 56

void cfl_store_dc_pred(MACROBLOCKD *const xd, const uint8_t *input,
                       CFL_PRED_TYPE pred_plane, int width);

void cfl_load_dc_pred(MACROBLOCKD *const xd, uint8_t *dst, int dst_stride,
                      TX_SIZE tx_size, CFL_PRED_TYPE pred_plane);
57 58 59 60 61 62 63 64 65 66

// TODO(ltrudeau) Remove this when 422 SIMD is added
void cfl_luma_subsampling_422_lbd(const uint8_t *input, int input_stride,
                                  int16_t *output_q3, int width, int height);
// TODO(ltrudeau) Remove this when 440 SIMD is added
void cfl_luma_subsampling_440_lbd(const uint8_t *input, int input_stride,
                                  int16_t *output_q3, int width, int height);
// TODO(ltrudeau) Remove this when 444 SIMD is added
void cfl_luma_subsampling_444_lbd(const uint8_t *input, int input_stride,
                                  int16_t *output_q3, int width, int height);
Luc Trudeau's avatar
Luc Trudeau committed
67
#endif  // AV1_COMMON_CFL_H_