vp9_invtrans.c 4.61 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,
55 56 57 58
                   tx_type, 4);
    } 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(short *input_dqcoeff, short *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) {
Jim Bankoski's avatar
Jim Bankoski committed
94
      vp9_ihtllm(xd->block[i].dqcoeff, xd->block[i].diff, 32, tx_type, 8);
95 96 97 98
    } else {
      vp9_inverse_transform_b_8x8(&blockd[i].dqcoeff[0],
                                  &blockd[i].diff[0], 32);
    }
John Koleszar's avatar
John Koleszar committed
99 100
  }
  for (i = 2; i < 11; i += 8) {
101 102
    TX_TYPE tx_type = get_tx_type_8x8(xd, &xd->block[i]);
    if (tx_type != DCT_DCT) {
Jim Bankoski's avatar
Jim Bankoski committed
103
      vp9_ihtllm(xd->block[i + 2].dqcoeff, xd->block[i].diff, 32, tx_type, 8);
104 105 106 107
    } else {
      vp9_inverse_transform_b_8x8(&blockd[i + 2].dqcoeff[0],
                                  &blockd[i].diff[0], 32);
    }
John Koleszar's avatar
John Koleszar committed
108
  }
109
}
110

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

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

121 122 123
void vp9_inverse_transform_mb_8x8(MACROBLOCKD *xd) {
  vp9_inverse_transform_mby_8x8(xd);
  vp9_inverse_transform_mbuv_8x8(xd);
124 125
}

126
void vp9_inverse_transform_b_16x16(short *input_dqcoeff,
Daniel Kang's avatar
Daniel Kang committed
127
                                   short *output_coeff, int pitch) {
128
  vp9_short_idct16x16(input_dqcoeff, output_coeff, pitch);
Daniel Kang's avatar
Daniel Kang committed
129 130
}

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

142 143 144
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
145
}
146 147 148 149 150 151 152 153 154 155 156 157 158

#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
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