vp9_invtrans.c 4.69 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1
/*
2
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar's avatar
John Koleszar committed
3
 *
4
 *  Use of this source code is governed by a BSD-style license
5 6
 *  that can be found in the LICENSE file in the root of the source
 *  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.
John Koleszar's avatar
John Koleszar committed
9 10
 */

11
#include "vp9/common/vp9_invtrans.h"
12
#include "./vp9_rtcd.h"
John Koleszar's avatar
John Koleszar committed
13

Paul Wilkins's avatar
Paul Wilkins committed
14 15
static void recon_dcblock(MACROBLOCKD *xd) {
  BLOCKD *b = &xd->block[24];
John Koleszar's avatar
John Koleszar committed
16
  int i;
John Koleszar's avatar
John Koleszar committed
17

John Koleszar's avatar
John Koleszar committed
18
  for (i = 0; i < 16; i++) {
Paul Wilkins's avatar
Paul Wilkins committed
19
    xd->block[i].dqcoeff[0] = b->diff[i];
John Koleszar's avatar
John Koleszar committed
20
  }
John Koleszar's avatar
John Koleszar committed
21
}
22

Paul Wilkins's avatar
Paul Wilkins committed
23 24
static void recon_dcblock_8x8(MACROBLOCKD *xd) {
  BLOCKD *b = &xd->block[24]; // for coeff 0, 2, 8, 10
25

Paul Wilkins's avatar
Paul Wilkins committed
26 27 28 29
  xd->block[0].dqcoeff[0] = b->diff[0];
  xd->block[4].dqcoeff[0] = b->diff[1];
  xd->block[8].dqcoeff[0] = b->diff[4];
  xd->block[12].dqcoeff[0] = b->diff[8];
30 31
}

32 33
void vp9_inverse_transform_b_4x4(MACROBLOCKD *xd, int block, int pitch) {
  BLOCKD *b = &xd->block[block];
John Koleszar's avatar
John Koleszar committed
34
  if (b->eob <= 1)
35
    xd->inv_xform4x4_1_x8(b->dqcoeff, b->diff, pitch);
John Koleszar's avatar
John Koleszar committed
36
  else
37
    xd->inv_xform4x4_x8(b->dqcoeff, b->diff, pitch);
John Koleszar's avatar
John Koleszar committed
38 39
}

40
void vp9_inverse_transform_mby_4x4(MACROBLOCKD *xd) {
John Koleszar's avatar
John Koleszar committed
41
  int i;
Paul Wilkins's avatar
Paul Wilkins committed
42
  BLOCKD *blockd = xd->block;
43
  int has_2nd_order = get_2nd_order_usage(xd);
John Koleszar's avatar
John Koleszar committed
44

45
  if (has_2nd_order) {
46
    /* do 2nd order transform on the dc block */
47
    vp9_short_inv_walsh4x4(blockd[24].dqcoeff, blockd[24].diff);
48 49
    recon_dcblock(xd);
  }
John Koleszar's avatar
John Koleszar committed
50

John Koleszar's avatar
John Koleszar committed
51
  for (i = 0; i < 16; i++) {
52 53
    TX_TYPE tx_type = get_tx_type_4x4(xd, &xd->block[i]);
    if (tx_type != DCT_DCT) {
Jim Bankoski's avatar
Jim Bankoski committed
54
      vp9_ihtllm(xd->block[i].dqcoeff, xd->block[i].diff, 32,
Scott LaVarnway's avatar
Scott LaVarnway committed
55
                   tx_type, 4, xd->block[i].eob);
56 57 58
    } else {
      vp9_inverse_transform_b_4x4(xd, i, 32);
    }
John Koleszar's avatar
John Koleszar committed
59
  }
John Koleszar's avatar
John Koleszar committed
60
}
61

62
void vp9_inverse_transform_mbuv_4x4(MACROBLOCKD *xd) {
John Koleszar's avatar
John Koleszar committed
63
  int i;
64

John Koleszar's avatar
John Koleszar committed
65
  for (i = 16; i < 24; i++) {
66
    vp9_inverse_transform_b_4x4(xd, i, 16);
John Koleszar's avatar
John Koleszar committed
67
  }
John Koleszar's avatar
John Koleszar committed
68 69
}

70 71 72
void vp9_inverse_transform_mb_4x4(MACROBLOCKD *xd) {
  vp9_inverse_transform_mby_4x4(xd);
  vp9_inverse_transform_mbuv_4x4(xd);
John Koleszar's avatar
John Koleszar committed
73
}
74

75
void vp9_inverse_transform_b_8x8(int16_t *input_dqcoeff, int16_t *output_coeff,
76
                                 int pitch) {
77
  vp9_short_idct8x8(input_dqcoeff, output_coeff, pitch);
78 79
}

80
void vp9_inverse_transform_mby_8x8(MACROBLOCKD *xd) {
John Koleszar's avatar
John Koleszar committed
81
  int i;
Paul Wilkins's avatar
Paul Wilkins committed
82
  BLOCKD *blockd = xd->block;
83
  int has_2nd_order = get_2nd_order_usage(xd);
84

85
  if (has_2nd_order) {
86
    // do 2nd order transform on the dc block
87
    vp9_short_ihaar2x2(blockd[24].dqcoeff, blockd[24].diff, 8);
88 89
    recon_dcblock_8x8(xd); // need to change for 8x8
  }
John Koleszar's avatar
John Koleszar committed
90 91

  for (i = 0; i < 9; i += 8) {
92 93
    TX_TYPE tx_type = get_tx_type_8x8(xd, &xd->block[i]);
    if (tx_type != DCT_DCT) {
Scott LaVarnway's avatar
Scott LaVarnway committed
94 95
      vp9_ihtllm(xd->block[i].dqcoeff, xd->block[i].diff, 32, tx_type, 8,
                 xd->block[i].eob);
96 97 98 99
    } else {
      vp9_inverse_transform_b_8x8(&blockd[i].dqcoeff[0],
                                  &blockd[i].diff[0], 32);
    }
John Koleszar's avatar
John Koleszar committed
100 101
  }
  for (i = 2; i < 11; i += 8) {
102 103
    TX_TYPE tx_type = get_tx_type_8x8(xd, &xd->block[i]);
    if (tx_type != DCT_DCT) {
Scott LaVarnway's avatar
Scott LaVarnway committed
104 105
      vp9_ihtllm(xd->block[i + 2].dqcoeff, xd->block[i].diff, 32, tx_type, 8,
                 xd->block[i + 2].eob);
106 107 108 109
    } else {
      vp9_inverse_transform_b_8x8(&blockd[i + 2].dqcoeff[0],
                                  &blockd[i].diff[0], 32);
    }
John Koleszar's avatar
John Koleszar committed
110
  }
111
}
112

113
void vp9_inverse_transform_mbuv_8x8(MACROBLOCKD *xd) {
John Koleszar's avatar
John Koleszar committed
114
  int i;
Paul Wilkins's avatar
Paul Wilkins committed
115
  BLOCKD *blockd = xd->block;
116

John Koleszar's avatar
John Koleszar committed
117
  for (i = 16; i < 24; i += 4) {
118
    vp9_inverse_transform_b_8x8(&blockd[i].dqcoeff[0],
Paul Wilkins's avatar
Paul Wilkins committed
119
                                &blockd[i].diff[0], 16);
John Koleszar's avatar
John Koleszar committed
120
  }
121 122
}

123 124 125
void vp9_inverse_transform_mb_8x8(MACROBLOCKD *xd) {
  vp9_inverse_transform_mby_8x8(xd);
  vp9_inverse_transform_mbuv_8x8(xd);
126 127
}

128 129
void vp9_inverse_transform_b_16x16(int16_t *input_dqcoeff,
                                   int16_t *output_coeff, int pitch) {
130
  vp9_short_idct16x16(input_dqcoeff, output_coeff, pitch);
Daniel Kang's avatar
Daniel Kang committed
131 132
}

133
void vp9_inverse_transform_mby_16x16(MACROBLOCKD *xd) {
134 135 136
  BLOCKD *bd = &xd->block[0];
  TX_TYPE tx_type = get_tx_type_16x16(xd, bd);
  if (tx_type != DCT_DCT) {
Scott LaVarnway's avatar
Scott LaVarnway committed
137
    vp9_ihtllm(bd->dqcoeff, bd->diff, 32, tx_type, 16, bd->eob);
138 139 140 141
  } else {
    vp9_inverse_transform_b_16x16(&xd->block[0].dqcoeff[0],
                                  &xd->block[0].diff[0], 32);
  }
Daniel Kang's avatar
Daniel Kang committed
142 143
}

144 145 146
void vp9_inverse_transform_mb_16x16(MACROBLOCKD *xd) {
  vp9_inverse_transform_mby_16x16(xd);
  vp9_inverse_transform_mbuv_8x8(xd);
Daniel Kang's avatar
Daniel Kang committed
147
}
148

149
#if CONFIG_TX32X32
150 151 152 153 154 155 156 157 158 159 160
void vp9_inverse_transform_sby_32x32(SUPERBLOCKD *xd_sb) {
  vp9_short_idct32x32(xd_sb->dqcoeff, xd_sb->diff, 64);
}

void vp9_inverse_transform_sbuv_16x16(SUPERBLOCKD *xd_sb) {
  vp9_inverse_transform_b_16x16(xd_sb->dqcoeff + 1024,
                                xd_sb->diff + 1024, 32);
  vp9_inverse_transform_b_16x16(xd_sb->dqcoeff + 1280,
                                xd_sb->diff + 1280, 32);
}
#endif