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
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-09-15 14:34:12 +02:00
|
|
|
#include "vpx_config.h"
|
2012-01-13 01:55:44 +01:00
|
|
|
#include "vpx_rtcd.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "vpx_mem/vpx_mem.h"
|
2012-01-13 01:55:44 +01:00
|
|
|
#include "blockd.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-03-29 20:24:53 +02:00
|
|
|
void vp8_build_intra_predictors_mby_s_c(MACROBLOCKD *x,
|
2012-02-28 20:12:30 +01:00
|
|
|
unsigned char * yabove_row,
|
|
|
|
unsigned char * yleft,
|
|
|
|
int left_stride,
|
2012-03-20 20:11:42 +01:00
|
|
|
unsigned char * ypred_ptr,
|
|
|
|
int y_stride)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
unsigned char yleft_col[16];
|
|
|
|
unsigned char ytop_left = yabove_row[-1];
|
|
|
|
int r, c, i;
|
|
|
|
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
2012-02-28 20:12:30 +01:00
|
|
|
yleft_col[i] = yleft[i* left_stride];
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* for Y */
|
2010-08-12 22:25:43 +02:00
|
|
|
switch (x->mode_info_context->mbmi.mode)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
case DC_PRED:
|
|
|
|
{
|
|
|
|
int expected_dc;
|
|
|
|
int i;
|
|
|
|
int shift;
|
|
|
|
int average = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (x->up_available || x->left_available)
|
|
|
|
{
|
|
|
|
if (x->up_available)
|
|
|
|
{
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
average += yabove_row[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x->left_available)
|
|
|
|
{
|
|
|
|
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
average += yleft_col[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shift = 3 + x->up_available + x->left_available;
|
|
|
|
expected_dc = (average + (1 << (shift - 1))) >> shift;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
expected_dc = 128;
|
|
|
|
}
|
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/*vpx_memset(ypred_ptr, expected_dc, 256);*/
|
2010-05-18 17:58:33 +02:00
|
|
|
for (r = 0; r < 16; r++)
|
|
|
|
{
|
|
|
|
vpx_memset(ypred_ptr, expected_dc, 16);
|
2012-03-20 20:11:42 +01:00
|
|
|
ypred_ptr += y_stride;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case V_PRED:
|
|
|
|
{
|
|
|
|
|
|
|
|
for (r = 0; r < 16; r++)
|
|
|
|
{
|
|
|
|
|
|
|
|
((int *)ypred_ptr)[0] = ((int *)yabove_row)[0];
|
|
|
|
((int *)ypred_ptr)[1] = ((int *)yabove_row)[1];
|
|
|
|
((int *)ypred_ptr)[2] = ((int *)yabove_row)[2];
|
|
|
|
((int *)ypred_ptr)[3] = ((int *)yabove_row)[3];
|
2012-03-20 20:11:42 +01:00
|
|
|
ypred_ptr += y_stride;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case H_PRED:
|
|
|
|
{
|
|
|
|
|
|
|
|
for (r = 0; r < 16; r++)
|
|
|
|
{
|
|
|
|
|
|
|
|
vpx_memset(ypred_ptr, yleft_col[r], 16);
|
2012-03-20 20:11:42 +01:00
|
|
|
ypred_ptr += y_stride;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TM_PRED:
|
|
|
|
{
|
|
|
|
|
|
|
|
for (r = 0; r < 16; r++)
|
|
|
|
{
|
|
|
|
for (c = 0; c < 16; c++)
|
|
|
|
{
|
|
|
|
int pred = yleft_col[r] + yabove_row[ c] - ytop_left;
|
|
|
|
|
|
|
|
if (pred < 0)
|
|
|
|
pred = 0;
|
|
|
|
|
|
|
|
if (pred > 255)
|
|
|
|
pred = 255;
|
|
|
|
|
|
|
|
ypred_ptr[c] = pred;
|
|
|
|
}
|
|
|
|
|
2012-03-20 20:11:42 +01:00
|
|
|
ypred_ptr += y_stride;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case B_PRED:
|
|
|
|
case NEARESTMV:
|
|
|
|
case NEARMV:
|
|
|
|
case ZEROMV:
|
|
|
|
case NEWMV:
|
|
|
|
case SPLITMV:
|
|
|
|
case MB_MODE_COUNT:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-21 20:59:05 +01:00
|
|
|
void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x,
|
|
|
|
unsigned char * uabove_row,
|
|
|
|
unsigned char * vabove_row,
|
|
|
|
unsigned char * uleft,
|
|
|
|
unsigned char * vleft,
|
|
|
|
int left_stride,
|
|
|
|
unsigned char * upred_ptr,
|
2012-03-20 20:11:42 +01:00
|
|
|
unsigned char * vpred_ptr,
|
|
|
|
int pred_stride)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2012-02-21 20:59:05 +01:00
|
|
|
unsigned char uleft_col[8];
|
2010-05-18 17:58:33 +02:00
|
|
|
unsigned char utop_left = uabove_row[-1];
|
2012-02-21 20:59:05 +01:00
|
|
|
unsigned char vleft_col[8];
|
2010-05-18 17:58:33 +02:00
|
|
|
unsigned char vtop_left = vabove_row[-1];
|
|
|
|
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
2012-02-21 20:59:05 +01:00
|
|
|
uleft_col[i] = uleft [i* left_stride];
|
|
|
|
vleft_col[i] = vleft [i* left_stride];
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2010-08-12 22:25:43 +02:00
|
|
|
switch (x->mode_info_context->mbmi.uv_mode)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
case DC_PRED:
|
|
|
|
{
|
|
|
|
int expected_udc;
|
|
|
|
int expected_vdc;
|
|
|
|
int i;
|
|
|
|
int shift;
|
|
|
|
int Uaverage = 0;
|
|
|
|
int Vaverage = 0;
|
|
|
|
|
|
|
|
if (x->up_available)
|
|
|
|
{
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
Uaverage += uabove_row[i];
|
|
|
|
Vaverage += vabove_row[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x->left_available)
|
|
|
|
{
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
Uaverage += uleft_col[i];
|
|
|
|
Vaverage += vleft_col[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!x->up_available && !x->left_available)
|
|
|
|
{
|
|
|
|
expected_udc = 128;
|
|
|
|
expected_vdc = 128;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
shift = 2 + x->up_available + x->left_available;
|
|
|
|
expected_udc = (Uaverage + (1 << (shift - 1))) >> shift;
|
|
|
|
expected_vdc = (Vaverage + (1 << (shift - 1))) >> shift;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/*vpx_memset(upred_ptr,expected_udc,64);*/
|
|
|
|
/*vpx_memset(vpred_ptr,expected_vdc,64);*/
|
2010-05-18 17:58:33 +02:00
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
vpx_memset(upred_ptr, expected_udc, 8);
|
|
|
|
vpx_memset(vpred_ptr, expected_vdc, 8);
|
2012-03-20 20:11:42 +01:00
|
|
|
upred_ptr += pred_stride;
|
|
|
|
vpred_ptr += pred_stride;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case V_PRED:
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
vpx_memcpy(upred_ptr, uabove_row, 8);
|
|
|
|
vpx_memcpy(vpred_ptr, vabove_row, 8);
|
2012-03-20 20:11:42 +01:00
|
|
|
upred_ptr += pred_stride;
|
|
|
|
vpred_ptr += pred_stride;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case H_PRED:
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
vpx_memset(upred_ptr, uleft_col[i], 8);
|
|
|
|
vpx_memset(vpred_ptr, vleft_col[i], 8);
|
2012-03-20 20:11:42 +01:00
|
|
|
upred_ptr += pred_stride;
|
|
|
|
vpred_ptr += pred_stride;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case TM_PRED:
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 8; j++)
|
|
|
|
{
|
|
|
|
int predu = uleft_col[i] + uabove_row[j] - utop_left;
|
|
|
|
int predv = vleft_col[i] + vabove_row[j] - vtop_left;
|
|
|
|
|
|
|
|
if (predu < 0)
|
|
|
|
predu = 0;
|
|
|
|
|
|
|
|
if (predu > 255)
|
|
|
|
predu = 255;
|
|
|
|
|
|
|
|
if (predv < 0)
|
|
|
|
predv = 0;
|
|
|
|
|
|
|
|
if (predv > 255)
|
|
|
|
predv = 255;
|
|
|
|
|
|
|
|
upred_ptr[j] = predu;
|
|
|
|
vpred_ptr[j] = predv;
|
|
|
|
}
|
|
|
|
|
2012-03-20 20:11:42 +01:00
|
|
|
upred_ptr += pred_stride;
|
|
|
|
vpred_ptr += pred_stride;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case B_PRED:
|
|
|
|
case NEARESTMV:
|
|
|
|
case NEARMV:
|
|
|
|
case ZEROMV:
|
|
|
|
case NEWMV:
|
|
|
|
case SPLITMV:
|
|
|
|
case MB_MODE_COUNT:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|