2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
2012-12-23 16:20:10 +01:00
|
|
|
#include "./vpx_config.h"
|
2012-11-09 02:09:30 +01:00
|
|
|
#include "vp9_rtcd.h"
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/encoder/vp9_quantize.h"
|
2012-11-27 22:59:17 +01:00
|
|
|
#include "vp9/common/vp9_reconintra.h"
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/encoder/vp9_encodemb.h"
|
2012-11-27 22:59:17 +01:00
|
|
|
#include "vp9/common/vp9_invtrans.h"
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/encoder/vp9_encodeintra.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-04-29 21:43:38 +02:00
|
|
|
static void encode_intra4x4block(MACROBLOCK *x, int ib, BLOCK_SIZE_TYPE bs);
|
2013-04-02 23:50:40 +02:00
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
int vp9_encode_intra(VP9_COMP *cpi, MACROBLOCK *x, int use_16x16_pred) {
|
2012-08-10 15:12:43 +02:00
|
|
|
MB_MODE_INFO * mbmi = &x->e_mbd.mode_info_context->mbmi;
|
2012-07-14 00:21:29 +02:00
|
|
|
(void) cpi;
|
2011-06-14 12:39:06 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
if (use_16x16_pred) {
|
2012-08-10 15:12:43 +02:00
|
|
|
mbmi->mode = DC_PRED;
|
|
|
|
mbmi->uv_mode = DC_PRED;
|
|
|
|
mbmi->ref_frame = INTRA_FRAME;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2013-02-20 19:16:24 +01:00
|
|
|
vp9_encode_intra16x16mby(&cpi->common, x);
|
2012-07-14 00:21:29 +02:00
|
|
|
} else {
|
2013-02-28 22:18:02 +01:00
|
|
|
int i;
|
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
for (i = 0; i < 16; i++) {
|
2013-04-26 16:19:43 +02:00
|
|
|
x->e_mbd.mode_info_context->bmi[i].as_mode.first = B_DC_PRED;
|
2013-04-29 21:43:38 +02:00
|
|
|
encode_intra4x4block(x, i, BLOCK_SIZE_MB16X16);
|
2011-06-14 12:39:06 +02:00
|
|
|
}
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2011-06-14 12:39:06 +02:00
|
|
|
|
2013-04-23 17:26:10 +02:00
|
|
|
return vp9_get_mb_ss(x->plane[0].src_diff);
|
2011-06-14 12:39:06 +02:00
|
|
|
}
|
2011-05-20 03:37:13 +02:00
|
|
|
|
2013-04-29 21:43:38 +02:00
|
|
|
static void encode_intra4x4block(MACROBLOCK *x, int ib,
|
|
|
|
BLOCK_SIZE_TYPE bsize) {
|
2013-04-02 23:50:40 +02:00
|
|
|
MACROBLOCKD * const xd = &x->e_mbd;
|
2012-10-16 01:41:41 +02:00
|
|
|
TX_TYPE tx_type;
|
2013-04-24 01:22:47 +02:00
|
|
|
uint8_t* const src =
|
2013-04-29 21:43:38 +02:00
|
|
|
raster_block_offset_uint8(xd, bsize, 0, ib,
|
2013-04-24 01:22:47 +02:00
|
|
|
x->plane[0].src.buf, x->plane[0].src.stride);
|
2013-04-25 20:15:38 +02:00
|
|
|
uint8_t* const dst =
|
2013-04-29 21:43:38 +02:00
|
|
|
raster_block_offset_uint8(xd, bsize, 0, ib,
|
2013-04-25 20:15:38 +02:00
|
|
|
xd->plane[0].dst.buf, xd->plane[0].dst.stride);
|
2013-04-23 17:26:10 +02:00
|
|
|
int16_t* const src_diff =
|
2013-04-29 21:43:38 +02:00
|
|
|
raster_block_offset_int16(xd, bsize, 0, ib,
|
2013-04-23 17:26:10 +02:00
|
|
|
x->plane[0].src_diff);
|
2013-04-25 00:01:35 +02:00
|
|
|
int16_t* const diff =
|
2013-04-29 21:43:38 +02:00
|
|
|
raster_block_offset_int16(xd, bsize, 0, ib,
|
2013-04-25 00:01:35 +02:00
|
|
|
xd->plane[0].diff);
|
2013-04-23 23:38:52 +02:00
|
|
|
int16_t* const coeff = BLOCK_OFFSET(x->plane[0].coeff, ib, 16);
|
2013-05-05 00:49:41 +02:00
|
|
|
const int bwl = b_width_log2(bsize), bhl = b_height_log2(bsize);
|
2011-05-20 03:37:13 +02:00
|
|
|
|
2013-05-05 00:49:41 +02:00
|
|
|
assert(ib < (1 << (bwl + bhl)));
|
2013-04-02 23:50:40 +02:00
|
|
|
|
2013-05-05 00:49:41 +02:00
|
|
|
vp9_intra4x4_predict(&x->e_mbd, ib, bsize,
|
2013-04-26 16:19:43 +02:00
|
|
|
xd->mode_info_context->bmi[ib].as_mode.first,
|
2013-04-25 20:15:38 +02:00
|
|
|
dst, xd->plane[0].dst.stride);
|
2013-05-05 00:49:41 +02:00
|
|
|
vp9_subtract_block(4, 4, src_diff, 4 << bwl,
|
2013-04-24 01:22:47 +02:00
|
|
|
src, x->plane[0].src.stride,
|
2013-04-25 20:15:38 +02:00
|
|
|
dst, xd->plane[0].dst.stride);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-03-06 00:18:06 +01:00
|
|
|
tx_type = get_tx_type_4x4(&x->e_mbd, ib);
|
2012-10-16 01:41:41 +02:00
|
|
|
if (tx_type != DCT_DCT) {
|
2013-05-05 00:49:41 +02:00
|
|
|
vp9_short_fht4x4(src_diff, coeff, 4 << bwl, tx_type);
|
2013-04-25 23:44:44 +02:00
|
|
|
x->quantize_b_4x4(x, ib, tx_type, 16);
|
2013-04-02 23:50:40 +02:00
|
|
|
vp9_short_iht4x4(BLOCK_OFFSET(xd->plane[0].dqcoeff, ib, 16),
|
2013-05-05 00:49:41 +02:00
|
|
|
diff, 4 << bwl, tx_type);
|
2012-10-22 20:55:29 +02:00
|
|
|
} else {
|
2013-05-05 00:49:41 +02:00
|
|
|
x->fwd_txm4x4(src_diff, coeff, 8 << bwl);
|
2013-04-25 23:44:44 +02:00
|
|
|
x->quantize_b_4x4(x, ib, tx_type, 16);
|
2013-04-04 21:03:27 +02:00
|
|
|
vp9_inverse_transform_b_4x4(&x->e_mbd, xd->plane[0].eobs[ib],
|
2013-04-02 23:50:40 +02:00
|
|
|
BLOCK_OFFSET(xd->plane[0].dqcoeff, ib, 16),
|
2013-05-05 00:49:41 +02:00
|
|
|
diff, 8 << bwl);
|
2012-09-10 07:42:35 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-05-05 00:49:41 +02:00
|
|
|
vp9_recon_b(dst, diff, 4 << bwl, dst, xd->plane[0].dst.stride);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2013-04-29 21:43:38 +02:00
|
|
|
void vp9_encode_intra4x4mby(MACROBLOCK *mb, BLOCK_SIZE_TYPE bsize) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int i;
|
2013-04-29 21:43:38 +02:00
|
|
|
int bwl = b_width_log2(bsize), bhl = b_height_log2(bsize);
|
|
|
|
int bc = 1 << (bwl + bhl);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-04-29 21:43:38 +02:00
|
|
|
for (i = 0; i < bc; i++)
|
|
|
|
encode_intra4x4block(mb, i, bsize);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2013-02-20 19:16:24 +01:00
|
|
|
void vp9_encode_intra16x16mby(VP9_COMMON *const cm, MACROBLOCK *x) {
|
2012-10-13 18:27:54 +02:00
|
|
|
MACROBLOCKD *xd = &x->e_mbd;
|
2011-11-04 19:29:51 +01:00
|
|
|
|
2013-04-15 18:31:27 +02:00
|
|
|
vp9_build_intra_predictors_sby_s(xd, BLOCK_SIZE_MB16X16);
|
2013-05-03 02:05:14 +02:00
|
|
|
vp9_encode_sby(cm, x, BLOCK_SIZE_MB16X16);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2013-02-20 19:16:24 +01:00
|
|
|
void vp9_encode_intra16x16mbuv(VP9_COMMON *const cm, MACROBLOCK *x) {
|
2012-10-13 18:27:54 +02:00
|
|
|
MACROBLOCKD *xd = &x->e_mbd;
|
|
|
|
|
2013-04-15 18:31:27 +02:00
|
|
|
vp9_build_intra_predictors_sbuv_s(xd, BLOCK_SIZE_MB16X16);
|
2013-05-03 02:05:14 +02:00
|
|
|
vp9_encode_sbuv(cm, x, BLOCK_SIZE_MB16X16);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|