2014-01-24 10:37:15 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* This file is part of Kvazaar HEVC encoder.
|
2014-02-21 13:00:20 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2014 Tampere University of Technology and others (see
|
2014-01-24 10:37:15 +00:00
|
|
|
* COPYING file).
|
|
|
|
*
|
|
|
|
* Kvazaar is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as published
|
|
|
|
* by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* Kvazaar is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* \file
|
2013-04-24 07:35:27 +00:00
|
|
|
*/
|
|
|
|
|
2013-09-18 09:16:03 +00:00
|
|
|
#include "inter.h"
|
|
|
|
|
2013-04-24 07:35:27 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2013-09-18 09:16:03 +00:00
|
|
|
|
2013-04-24 07:35:27 +00:00
|
|
|
#include "config.h"
|
2013-09-23 15:07:16 +00:00
|
|
|
#include "filter.h"
|
2014-11-20 16:38:54 +00:00
|
|
|
#include "strategies/strategies-ipol.h"
|
2013-04-24 07:35:27 +00:00
|
|
|
|
2013-09-19 12:08:30 +00:00
|
|
|
/**
|
|
|
|
* \brief Set block info to the CU structure
|
|
|
|
* \param pic picture to use
|
|
|
|
* \param x_cu x CU position (smallest CU)
|
|
|
|
* \param y_cu y CU position (smallest CU)
|
|
|
|
* \param depth current CU depth
|
|
|
|
* \param cur_cu CU to take the settings from
|
|
|
|
* \returns Void
|
2013-04-24 07:35:27 +00:00
|
|
|
*/
|
2014-06-05 12:54:58 +00:00
|
|
|
void inter_set_block(videoframe* frame, uint32_t x_cu, uint32_t y_cu, uint8_t depth, cu_info* cur_cu)
|
2013-04-24 07:35:27 +00:00
|
|
|
{
|
2013-09-25 13:11:31 +00:00
|
|
|
uint32_t x, y;
|
2013-09-19 12:08:30 +00:00
|
|
|
// Width in smallest CU
|
|
|
|
int block_scu_width = (LCU_WIDTH>>depth)/(LCU_WIDTH>>MAX_DEPTH);
|
2014-01-14 15:14:56 +00:00
|
|
|
int tr_depth = (depth == 0 ? 1 : depth);
|
2013-09-19 12:08:30 +00:00
|
|
|
// Loop through all the block in the area of cur_cu
|
|
|
|
for (y = y_cu; y < y_cu + block_scu_width; y++) {
|
|
|
|
for (x = x_cu; x < x_cu + block_scu_width; x++) {
|
2014-06-05 12:54:58 +00:00
|
|
|
cu_info * const cu = videoframe_get_cu(frame, x, y);
|
2013-09-25 13:11:31 +00:00
|
|
|
// Set all SCU's to this blocks values at the bottom most depth.
|
2014-06-05 08:41:58 +00:00
|
|
|
cu->depth = depth;
|
|
|
|
cu->type = CU_INTER;
|
|
|
|
cu->part_size = SIZE_2Nx2N;
|
|
|
|
cu->inter.mode = cur_cu->inter.mode;
|
|
|
|
cu->inter.mv[0] = cur_cu->inter.mv[0];
|
|
|
|
cu->inter.mv[1] = cur_cu->inter.mv[1];
|
|
|
|
cu->inter.mv_dir = cur_cu->inter.mv_dir;
|
|
|
|
cu->inter.mv_ref = cur_cu->inter.mv_ref;
|
|
|
|
cu->tr_depth = tr_depth;
|
2013-04-24 07:35:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-19 12:08:30 +00:00
|
|
|
/**
|
|
|
|
* \brief Reconstruct inter block
|
|
|
|
* \param ref picture to copy the data from
|
|
|
|
* \param xpos block x position
|
|
|
|
* \param ypos block y position
|
|
|
|
* \param width block width
|
|
|
|
* \param mv[2] motion vector
|
2014-03-03 12:51:36 +00:00
|
|
|
* \param lcu destination lcu
|
2013-09-19 12:08:30 +00:00
|
|
|
* \returns Void
|
2013-09-12 15:50:11 +00:00
|
|
|
*/
|
2014-06-11 08:19:33 +00:00
|
|
|
void inter_recon_lcu(const encoder_state * const encoder_state, const image * const ref, int32_t xpos, int32_t ypos,int32_t width, const int16_t mv_param[2], lcu_t *lcu)
|
2013-09-12 15:50:11 +00:00
|
|
|
{
|
|
|
|
int x,y,coord_x,coord_y;
|
2013-09-30 15:01:21 +00:00
|
|
|
int16_t mv[2] = { mv_param[0], mv_param[1] };
|
2013-09-12 15:50:11 +00:00
|
|
|
|
2014-03-03 12:51:36 +00:00
|
|
|
int32_t dst_width_c = LCU_WIDTH>>1; //!< Destination picture width in chroma pixels
|
2013-09-19 12:08:30 +00:00
|
|
|
int32_t ref_width_c = ref->width>>1; //!< Reference picture width in chroma pixels
|
2013-09-12 15:50:11 +00:00
|
|
|
|
2013-09-19 12:08:30 +00:00
|
|
|
// negative overflow flag
|
2014-05-06 08:13:18 +00:00
|
|
|
int8_t overflow_neg_x = (encoder_state->tile->lcu_offset_x * LCU_WIDTH + xpos + (mv[0]>>2) < 0)?1:0;
|
|
|
|
int8_t overflow_neg_y = (encoder_state->tile->lcu_offset_y * LCU_WIDTH + ypos + (mv[1]>>2) < 0)?1:0;
|
2013-09-12 15:50:11 +00:00
|
|
|
|
2013-09-19 12:08:30 +00:00
|
|
|
// positive overflow flag
|
2014-05-06 08:13:18 +00:00
|
|
|
int8_t overflow_pos_x = (encoder_state->tile->lcu_offset_x * LCU_WIDTH + xpos + (mv[0]>>2) + width > ref->width )?1:0;
|
|
|
|
int8_t overflow_pos_y = (encoder_state->tile->lcu_offset_y * LCU_WIDTH + ypos + (mv[1]>>2) + width > ref->height)?1:0;
|
2013-09-19 12:08:30 +00:00
|
|
|
|
2013-09-23 15:07:16 +00:00
|
|
|
// Chroma half-pel
|
|
|
|
#define HALFPEL_CHROMA_WIDTH ((LCU_WIDTH>>1) + 8)
|
2013-09-25 11:28:00 +00:00
|
|
|
int8_t chroma_halfpel = ((mv[0]>>2)&1) || ((mv[1]>>2)&1); //!< (luma integer mv) lsb is set -> chroma is half-pel
|
2014-12-11 14:38:43 +00:00
|
|
|
pixel halfpel_src_u[HALFPEL_CHROMA_WIDTH * HALFPEL_CHROMA_WIDTH]; //!< U source block for interpolation
|
|
|
|
pixel halfpel_src_v[HALFPEL_CHROMA_WIDTH * HALFPEL_CHROMA_WIDTH]; //!< V source block for interpolation
|
|
|
|
pixel *halfpel_src_off_u = &halfpel_src_u[HALFPEL_CHROMA_WIDTH * 4 + 4]; //!< halfpel_src_u with offset (4,4)
|
|
|
|
pixel *halfpel_src_off_v = &halfpel_src_v[HALFPEL_CHROMA_WIDTH * 4 + 4]; //!< halfpel_src_v with offset (4,4)
|
|
|
|
pixel halfpel_u[LCU_WIDTH * LCU_WIDTH]; //!< interpolated 2W x 2H block (u)
|
|
|
|
pixel halfpel_v[LCU_WIDTH * LCU_WIDTH]; //!< interpolated 2W x 2H block (v)
|
2013-09-23 15:07:16 +00:00
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
// Luma quarter-pel
|
2014-05-14 01:49:34 +00:00
|
|
|
int8_t fractional_mv = (mv[0]&1) || (mv[1]&1) || (mv[0]&2) || (mv[1]&2); // either of 2 lowest bits of mv set -> mv is fractional
|
2013-09-12 15:50:11 +00:00
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
if(fractional_mv) {
|
|
|
|
int y_off_x = (mv[0]&3);
|
|
|
|
int y_off_y = (mv[1]&3);
|
2013-09-24 12:43:20 +00:00
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
int c_off_x = (mv[0]&7);
|
|
|
|
int c_off_y = (mv[1]&7);
|
2013-09-23 15:07:16 +00:00
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
int y,x;
|
|
|
|
|
2014-05-14 01:49:34 +00:00
|
|
|
#define FILTER_SIZE_Y 8 //Luma filter size
|
|
|
|
#define FILTER_SIZE_C 4 //Chroma filter size
|
2014-05-14 01:42:02 +00:00
|
|
|
|
|
|
|
// Fractional luma 1/4-pel
|
2014-12-11 14:38:43 +00:00
|
|
|
pixel qpel_src_y[(LCU_WIDTH+FILTER_SIZE_Y) * (LCU_WIDTH+FILTER_SIZE_Y)];
|
|
|
|
pixel* qpel_src_off_y = &qpel_src_y[(width+FILTER_SIZE_Y)*(FILTER_SIZE_Y>>1)+(FILTER_SIZE_Y>>1)];
|
|
|
|
pixel qpel_dst_y[LCU_WIDTH*LCU_WIDTH*16];
|
2014-03-03 12:51:36 +00:00
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
// Fractional chroma 1/8-pel
|
|
|
|
int width_c = width>>1;
|
2014-12-11 14:38:43 +00:00
|
|
|
pixel octpel_src_u[((LCU_WIDTH>>1)+FILTER_SIZE_C) * ((LCU_WIDTH>>1)+FILTER_SIZE_C)];
|
|
|
|
pixel* octpel_src_off_u = &octpel_src_u[(width_c+FILTER_SIZE_C)*(FILTER_SIZE_C>>1)+(FILTER_SIZE_C>>1)];
|
|
|
|
pixel octpel_dst_u[(LCU_WIDTH >> 1)*(LCU_WIDTH >> 1) * 64];
|
2013-09-19 12:08:30 +00:00
|
|
|
|
2014-12-11 14:38:43 +00:00
|
|
|
pixel octpel_src_v[((LCU_WIDTH >> 1) + FILTER_SIZE_C) * ((LCU_WIDTH >> 1) + FILTER_SIZE_C)];
|
|
|
|
pixel* octpel_src_off_v = &octpel_src_v[(width_c + FILTER_SIZE_C)*(FILTER_SIZE_C >> 1) + (FILTER_SIZE_C >> 1)];
|
|
|
|
pixel octpel_dst_v[(LCU_WIDTH >> 1)*(LCU_WIDTH >> 1) * 64];
|
2013-09-19 12:08:30 +00:00
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
// Fractional luma
|
|
|
|
extend_borders(xpos, ypos, mv[0]>>2, mv[1]>>2, encoder_state->tile->lcu_offset_x * LCU_WIDTH, encoder_state->tile->lcu_offset_y * LCU_WIDTH,
|
2014-11-06 13:59:10 +00:00
|
|
|
ref->y, ref->width, ref->height, FILTER_SIZE_Y, width, width, qpel_src_y);
|
2014-05-14 01:42:02 +00:00
|
|
|
|
|
|
|
filter_inter_quarterpel_luma(encoder_state->encoder_control, qpel_src_off_y, width+FILTER_SIZE_Y, width,
|
|
|
|
width, qpel_dst_y, width*4, y_off_x, y_off_y);
|
|
|
|
|
|
|
|
//Fractional chroma U
|
|
|
|
extend_borders(xpos>>1, ypos>>1, (mv[0]>>2)>>1, (mv[1]>>2)>>1, encoder_state->tile->lcu_offset_x * (LCU_WIDTH>>1), encoder_state->tile->lcu_offset_y * (LCU_WIDTH>>1),
|
2014-11-06 13:59:10 +00:00
|
|
|
ref->u, ref->width>>1, ref->height>>1, FILTER_SIZE_C, width_c, width_c, octpel_src_u);
|
2014-05-14 01:42:02 +00:00
|
|
|
|
|
|
|
filter_inter_octpel_chroma(encoder_state->encoder_control, octpel_src_off_u, width_c+FILTER_SIZE_C, width_c,
|
|
|
|
width_c, octpel_dst_u, width_c*8, c_off_x, c_off_y);
|
2014-03-03 12:51:36 +00:00
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
//Fractional chroma V
|
|
|
|
extend_borders(xpos>>1, ypos>>1, (mv[0]>>2)>>1, (mv[1]>>2)>>1, encoder_state->tile->lcu_offset_x * (LCU_WIDTH>>1), encoder_state->tile->lcu_offset_y * (LCU_WIDTH>>1),
|
2014-11-06 13:59:10 +00:00
|
|
|
ref->v, ref->width>>1, ref->height>>1, FILTER_SIZE_C, width_c, width_c, octpel_src_v);
|
2013-09-19 12:08:30 +00:00
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
filter_inter_octpel_chroma(encoder_state->encoder_control, octpel_src_off_v, width_c+FILTER_SIZE_C, width_c,
|
|
|
|
width_c, octpel_dst_v, width_c*8, c_off_x, c_off_y);
|
2013-09-19 12:08:30 +00:00
|
|
|
|
2015-01-15 09:56:25 +00:00
|
|
|
//Sample fractional pixels for luma
|
2014-05-14 01:42:02 +00:00
|
|
|
for(y = 0; y < width; ++y) {
|
|
|
|
int y_in_lcu = ((y+ypos) & ((LCU_WIDTH)-1));
|
|
|
|
int qpel_y = y*4+y_off_y;
|
|
|
|
for(x = 0; x < width; ++x) {
|
|
|
|
int x_in_lcu = ((x+xpos) & ((LCU_WIDTH)-1));
|
|
|
|
int qpel_x = x*4+y_off_x;
|
2015-01-15 09:47:00 +00:00
|
|
|
lcu->rec.y[y_in_lcu * LCU_WIDTH + x_in_lcu] = (pixel)qpel_dst_y[qpel_y*(width*4)+qpel_x];
|
2013-09-12 15:50:11 +00:00
|
|
|
}
|
2014-05-14 01:42:02 +00:00
|
|
|
}
|
2015-01-15 09:56:25 +00:00
|
|
|
//Sample fractional pixels for chroma
|
2014-05-14 01:42:02 +00:00
|
|
|
for(y = 0; y < width_c; ++y) {
|
|
|
|
int y_in_lcu = ((y+(ypos>>1)) & ((LCU_WIDTH>>1)-1));
|
|
|
|
int qpel_y = y*8+c_off_y;
|
|
|
|
for(x = 0; x < width_c; ++x) {
|
|
|
|
int x_in_lcu = ((x+(xpos>>1)) & ((LCU_WIDTH>>1)-1));
|
|
|
|
int qpel_x = x*8+c_off_x;
|
2015-01-15 09:47:00 +00:00
|
|
|
lcu->rec.u[y_in_lcu * dst_width_c + x_in_lcu] = (pixel)octpel_dst_u[qpel_y*(width_c*8)+qpel_x];
|
|
|
|
lcu->rec.v[y_in_lcu * dst_width_c + x_in_lcu] = (pixel)octpel_dst_v[qpel_y*(width_c*8)+qpel_x];
|
2014-05-14 01:42:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mv[0] >>= 2;
|
|
|
|
mv[1] >>= 2;
|
|
|
|
|
|
|
|
// Chroma half-pel
|
|
|
|
// get half-pel interpolated block and push it to output
|
|
|
|
if(!fractional_mv) {
|
|
|
|
if(chroma_halfpel) {
|
|
|
|
int halfpel_y, halfpel_x;
|
|
|
|
int abs_mv_x = mv[0]&1;
|
|
|
|
int abs_mv_y = mv[1]&1;
|
|
|
|
int8_t overflow_neg_y_temp,overflow_pos_y_temp,overflow_neg_x_temp,overflow_pos_x_temp;
|
|
|
|
// Fill source blocks with data from reference, -4...width+4
|
|
|
|
for (halfpel_y = 0, y = (ypos>>1) - 4; y < ((ypos + width)>>1) + 4; halfpel_y++, y++) {
|
|
|
|
// calculate y-pixel offset
|
|
|
|
coord_y = (y + encoder_state->tile->lcu_offset_y * (LCU_WIDTH>>1)) + (mv[1]>>1);
|
2013-09-12 15:50:11 +00:00
|
|
|
|
2013-09-19 12:08:30 +00:00
|
|
|
// On y-overflow set coord_y accordingly
|
2014-05-14 01:42:02 +00:00
|
|
|
overflow_neg_y_temp = (coord_y < 0) ? 1 : 0;
|
|
|
|
overflow_pos_y_temp = (coord_y >= ref->height>>1) ? 1 : 0;
|
|
|
|
if (overflow_neg_y_temp) coord_y = 0;
|
|
|
|
else if (overflow_pos_y_temp) coord_y = (ref->height>>1) - 1;
|
|
|
|
coord_y *= ref_width_c;
|
2014-03-06 16:14:01 +00:00
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
for (halfpel_x = 0, x = (xpos>>1) - 4; x < ((xpos + width)>>1) + 4; halfpel_x++, x++) {
|
|
|
|
coord_x = (x + encoder_state->tile->lcu_offset_x * (LCU_WIDTH>>1)) + (mv[0]>>1);
|
2014-03-06 16:14:01 +00:00
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
// On x-overflow set coord_x accordingly
|
|
|
|
overflow_neg_x_temp = (coord_x < 0) ? 1 : 0;
|
|
|
|
overflow_pos_x_temp = (coord_x >= ref_width_c) ? 1 : 0;
|
|
|
|
if (overflow_neg_x_temp) coord_x = 0;
|
|
|
|
else if (overflow_pos_x_temp) coord_x = ref_width_c - 1;
|
|
|
|
|
|
|
|
// Store source block data (with extended borders)
|
2014-11-06 13:59:10 +00:00
|
|
|
halfpel_src_u[halfpel_y*HALFPEL_CHROMA_WIDTH + halfpel_x] = ref->u[coord_y + coord_x];
|
|
|
|
halfpel_src_v[halfpel_y*HALFPEL_CHROMA_WIDTH + halfpel_x] = ref->v[coord_y + coord_x];
|
2014-05-14 01:42:02 +00:00
|
|
|
}
|
2013-09-12 15:50:11 +00:00
|
|
|
}
|
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
// Filter the block to half-pel resolution
|
|
|
|
filter_inter_halfpel_chroma(encoder_state->encoder_control, halfpel_src_off_u, HALFPEL_CHROMA_WIDTH, width>>1, width>>1, halfpel_u, LCU_WIDTH, abs_mv_x, abs_mv_y);
|
|
|
|
filter_inter_halfpel_chroma(encoder_state->encoder_control, halfpel_src_off_v, HALFPEL_CHROMA_WIDTH, width>>1, width>>1, halfpel_v, LCU_WIDTH, abs_mv_x, abs_mv_y);
|
|
|
|
|
|
|
|
// Assign filtered pixels to output, take every second half-pel sample with offset of abs_mv_y/x
|
|
|
|
for (halfpel_y = abs_mv_y, y = ypos>>1; y < (ypos + width)>>1; halfpel_y += 2, y++) {
|
|
|
|
for (halfpel_x = abs_mv_x, x = xpos>>1; x < (xpos + width)>>1; halfpel_x += 2, x++) {
|
2014-03-03 12:51:36 +00:00
|
|
|
int x_in_lcu = (x & ((LCU_WIDTH>>1)-1));
|
|
|
|
int y_in_lcu = (y & ((LCU_WIDTH>>1)-1));
|
2015-01-15 09:47:00 +00:00
|
|
|
lcu->rec.u[y_in_lcu*dst_width_c + x_in_lcu] = (pixel)halfpel_u[halfpel_y*LCU_WIDTH + halfpel_x];
|
|
|
|
lcu->rec.v[y_in_lcu*dst_width_c + x_in_lcu] = (pixel)halfpel_v[halfpel_y*LCU_WIDTH + halfpel_x];
|
2014-05-14 01:42:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-03 12:51:36 +00:00
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
// With overflow present, more checking
|
|
|
|
if (overflow_neg_x || overflow_neg_y || overflow_pos_x || overflow_pos_y) {
|
|
|
|
// Copy Luma with boundary checking
|
|
|
|
for (y = ypos; y < ypos + width; y++) {
|
|
|
|
for (x = xpos; x < xpos + width; x++) {
|
|
|
|
int x_in_lcu = (x & ((LCU_WIDTH)-1));
|
|
|
|
int y_in_lcu = (y & ((LCU_WIDTH)-1));
|
2013-09-12 15:50:11 +00:00
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
coord_x = (x + encoder_state->tile->lcu_offset_x * LCU_WIDTH) + mv[0];
|
|
|
|
coord_y = (y + encoder_state->tile->lcu_offset_y * LCU_WIDTH) + mv[1];
|
2013-09-23 15:07:16 +00:00
|
|
|
overflow_neg_x = (coord_x < 0)?1:0;
|
2014-05-14 01:42:02 +00:00
|
|
|
overflow_neg_y = (coord_y < 0)?1:0;
|
2013-09-12 15:50:11 +00:00
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
overflow_pos_x = (coord_x >= ref->width )?1:0;
|
|
|
|
overflow_pos_y = (coord_y >= ref->height)?1:0;
|
2013-09-12 15:50:11 +00:00
|
|
|
|
2013-09-23 15:07:16 +00:00
|
|
|
// On x-overflow set coord_x accordingly
|
2014-05-14 01:42:02 +00:00
|
|
|
if (overflow_neg_x) {
|
2013-09-23 15:07:16 +00:00
|
|
|
coord_x = 0;
|
2014-05-14 01:42:02 +00:00
|
|
|
} else if (overflow_pos_x) {
|
|
|
|
coord_x = ref->width - 1;
|
2013-09-23 15:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// On y-overflow set coord_y accordingly
|
2014-05-14 01:42:02 +00:00
|
|
|
if (overflow_neg_y) {
|
2013-09-23 15:07:16 +00:00
|
|
|
coord_y = 0;
|
2014-05-14 01:42:02 +00:00
|
|
|
} else if (overflow_pos_y) {
|
|
|
|
coord_y = ref->height - 1;
|
2013-09-23 15:07:16 +00:00
|
|
|
}
|
|
|
|
|
2014-05-14 01:42:02 +00:00
|
|
|
// set destination to (corrected) pixel value from the reference
|
2014-11-06 13:59:10 +00:00
|
|
|
lcu->rec.y[y_in_lcu * LCU_WIDTH + x_in_lcu] = ref->y[coord_y*ref->width + coord_x];
|
2013-09-23 15:07:16 +00:00
|
|
|
}
|
2013-09-12 15:50:11 +00:00
|
|
|
}
|
2014-05-14 01:42:02 +00:00
|
|
|
|
|
|
|
if(!chroma_halfpel) {
|
|
|
|
// Copy Chroma with boundary checking
|
|
|
|
// TODO: chroma fractional pixel interpolation
|
|
|
|
for (y = ypos>>1; y < (ypos + width)>>1; y++) {
|
|
|
|
for (x = xpos>>1; x < (xpos + width)>>1; x++) {
|
|
|
|
int x_in_lcu = (x & ((LCU_WIDTH>>1)-1));
|
|
|
|
int y_in_lcu = (y & ((LCU_WIDTH>>1)-1));
|
|
|
|
|
|
|
|
coord_x = (x + encoder_state->tile->lcu_offset_x * (LCU_WIDTH >> 1)) + (mv[0]>>1);
|
|
|
|
coord_y = (y + encoder_state->tile->lcu_offset_y * (LCU_WIDTH >> 1)) + (mv[1]>>1);
|
|
|
|
|
|
|
|
overflow_neg_x = (coord_x < 0)?1:0;
|
|
|
|
overflow_neg_y = (y + (mv[1]>>1) < 0)?1:0;
|
|
|
|
|
|
|
|
overflow_pos_x = (coord_x >= ref->width>>1 )?1:0;
|
|
|
|
overflow_pos_y = (coord_y >= ref->height>>1)?1:0;
|
|
|
|
|
|
|
|
// On x-overflow set coord_x accordingly
|
|
|
|
if(overflow_neg_x) {
|
|
|
|
coord_x = 0;
|
|
|
|
} else if(overflow_pos_x) {
|
|
|
|
coord_x = (ref->width>>1) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// On y-overflow set coord_y accordingly
|
|
|
|
if(overflow_neg_y) {
|
|
|
|
coord_y = 0;
|
|
|
|
} else if(overflow_pos_y) {
|
|
|
|
coord_y = (ref->height>>1) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set destinations to (corrected) pixel value from the reference
|
2014-11-06 13:59:10 +00:00
|
|
|
lcu->rec.u[y_in_lcu*dst_width_c + x_in_lcu] = ref->u[coord_y * ref_width_c + coord_x];
|
|
|
|
lcu->rec.v[y_in_lcu*dst_width_c + x_in_lcu] = ref->v[coord_y * ref_width_c + coord_x];
|
2014-05-14 01:42:02 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-12 15:50:11 +00:00
|
|
|
}
|
2014-05-14 01:42:02 +00:00
|
|
|
} else { //If no overflow, we can copy without checking boundaries
|
|
|
|
// Copy Luma
|
|
|
|
for (y = ypos; y < ypos + width; y++) {
|
|
|
|
int y_in_lcu = (y & ((LCU_WIDTH)-1));
|
|
|
|
coord_y = ((y + encoder_state->tile->lcu_offset_y * LCU_WIDTH) + mv[1]) * ref->width; // pre-calculate
|
|
|
|
for (x = xpos; x < xpos + width; x++) {
|
|
|
|
int x_in_lcu = (x & ((LCU_WIDTH)-1));
|
2013-09-12 15:50:11 +00:00
|
|
|
|
2014-11-06 13:59:10 +00:00
|
|
|
lcu->rec.y[y_in_lcu * LCU_WIDTH + x_in_lcu] = ref->y[coord_y + (x + encoder_state->tile->lcu_offset_x * LCU_WIDTH) + mv[0]];
|
2014-05-14 01:42:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!chroma_halfpel) {
|
|
|
|
// Copy Chroma
|
|
|
|
// TODO: chroma fractional pixel interpolation
|
|
|
|
for (y = ypos>>1; y < (ypos + width)>>1; y++) {
|
|
|
|
int y_in_lcu = (y & ((LCU_WIDTH>>1)-1));
|
|
|
|
coord_y = ((y + encoder_state->tile->lcu_offset_y * (LCU_WIDTH>>1)) + (mv[1]>>1)) * ref_width_c; // pre-calculate
|
|
|
|
for (x = xpos>>1; x < (xpos + width)>>1; x++) {
|
|
|
|
int x_in_lcu = (x & ((LCU_WIDTH>>1)-1));
|
2014-11-06 13:59:10 +00:00
|
|
|
lcu->rec.u[y_in_lcu*dst_width_c + x_in_lcu] = ref->u[coord_y + (x + encoder_state->tile->lcu_offset_x * (LCU_WIDTH>>1)) + (mv[0]>>1)];
|
|
|
|
lcu->rec.v[y_in_lcu*dst_width_c + x_in_lcu] = ref->v[coord_y + (x + encoder_state->tile->lcu_offset_x * (LCU_WIDTH>>1)) + (mv[0]>>1)];
|
2014-05-14 01:42:02 +00:00
|
|
|
}
|
2013-09-23 15:07:16 +00:00
|
|
|
}
|
2013-09-12 15:50:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-16 13:37:24 +00:00
|
|
|
}
|
|
|
|
|
2013-09-19 12:08:30 +00:00
|
|
|
/**
|
2013-10-11 08:59:10 +00:00
|
|
|
* \brief Get merge candidates for current block
|
2013-09-19 12:08:30 +00:00
|
|
|
* \param encoder encoder control struct to use
|
|
|
|
* \param x_cu block x position in SCU
|
|
|
|
* \param y_cu block y position in SCU
|
|
|
|
* \param depth current block depth
|
2013-10-11 08:59:10 +00:00
|
|
|
* \param b0 candidate b0
|
|
|
|
* \param b1 candidate b1
|
|
|
|
* \param b2 candidate b2
|
|
|
|
* \param a0 candidate a0
|
|
|
|
* \param a1 candidate a1
|
2013-09-19 12:08:30 +00:00
|
|
|
*/
|
2014-03-03 14:08:35 +00:00
|
|
|
void inter_get_spatial_merge_candidates(int32_t x, int32_t y, int8_t depth, cu_info **b0, cu_info **b1,
|
|
|
|
cu_info **b2,cu_info **a0,cu_info **a1, lcu_t *lcu)
|
2013-09-16 13:37:24 +00:00
|
|
|
{
|
2013-09-19 12:08:30 +00:00
|
|
|
uint8_t cur_block_in_scu = (LCU_WIDTH>>depth) / CU_MIN_SIZE_PIXELS; //!< the width of the current block on SCU
|
2013-09-16 13:37:24 +00:00
|
|
|
/*
|
|
|
|
Predictor block locations
|
2013-09-18 07:15:05 +00:00
|
|
|
____ _______
|
2013-09-16 13:37:24 +00:00
|
|
|
|B2|______|B1|B0|
|
|
|
|
| |
|
|
|
|
| Cur CU |
|
|
|
|
__| |
|
|
|
|
|A1|_________|
|
|
|
|
|A0|
|
2014-02-21 13:00:20 +00:00
|
|
|
*/
|
2014-04-03 10:48:42 +00:00
|
|
|
int32_t x_cu = (x & (LCU_WIDTH - 1)) >> MAX_DEPTH; //!< coordinates from top-left of this LCU
|
|
|
|
int32_t y_cu = (y & (LCU_WIDTH - 1)) >> MAX_DEPTH;
|
2014-03-03 14:25:33 +00:00
|
|
|
cu_info* cu = &lcu->cu[LCU_CU_OFFSET];
|
2013-09-19 12:08:30 +00:00
|
|
|
// A0 and A1 availability testing
|
2014-03-03 14:08:35 +00:00
|
|
|
if (x != 0) {
|
2014-03-03 14:25:33 +00:00
|
|
|
*a1 = &cu[x_cu - 1 + (y_cu + cur_block_in_scu - 1) * LCU_T_CU_WIDTH];
|
2013-10-11 08:59:10 +00:00
|
|
|
if (!(*a1)->coded) *a1 = NULL;
|
2013-09-16 13:37:24 +00:00
|
|
|
|
2014-03-03 14:08:35 +00:00
|
|
|
if (y_cu + cur_block_in_scu < LCU_WIDTH>>3) {
|
2014-03-03 14:25:33 +00:00
|
|
|
*a0 = &cu[x_cu - 1 + (y_cu + cur_block_in_scu) * LCU_T_CU_WIDTH];
|
2013-10-11 08:59:10 +00:00
|
|
|
if (!(*a0)->coded) *a0 = NULL;
|
2013-09-16 13:37:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-19 12:08:30 +00:00
|
|
|
// B0, B1 and B2 availability testing
|
2014-03-03 14:08:35 +00:00
|
|
|
if (y != 0) {
|
|
|
|
if (x_cu + cur_block_in_scu < LCU_WIDTH>>3) {
|
2014-03-05 10:53:35 +00:00
|
|
|
*b0 = &cu[x_cu + cur_block_in_scu + (y_cu - 1) * LCU_T_CU_WIDTH];
|
|
|
|
if (!(*b0)->coded) *b0 = NULL;
|
|
|
|
} else if(y_cu == 0) {
|
2014-03-03 14:25:33 +00:00
|
|
|
// Special case, top-right cu from LCU is the last in lcu->cu array
|
2014-03-03 14:08:35 +00:00
|
|
|
*b0 = &lcu->cu[LCU_T_CU_WIDTH*LCU_T_CU_WIDTH];
|
2014-03-05 10:53:35 +00:00
|
|
|
if (!(*b0)->coded) *b0 = NULL;
|
2013-10-02 12:10:40 +00:00
|
|
|
}
|
2014-03-06 16:14:01 +00:00
|
|
|
|
2014-03-03 14:25:33 +00:00
|
|
|
*b1 = &cu[x_cu + cur_block_in_scu - 1 + (y_cu - 1) * LCU_T_CU_WIDTH];
|
2013-10-11 08:59:10 +00:00
|
|
|
if (!(*b1)->coded) *b1 = NULL;
|
2013-09-16 13:37:24 +00:00
|
|
|
|
2014-03-04 13:32:15 +00:00
|
|
|
if (x != 0) {
|
2014-03-03 14:25:33 +00:00
|
|
|
*b2 = &cu[x_cu - 1 + (y_cu - 1) * LCU_T_CU_WIDTH];
|
2013-10-11 08:59:10 +00:00
|
|
|
if(!(*b2)->coded) *b2 = NULL;
|
2013-09-16 13:37:24 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-11 08:59:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Get MV prediction for current block
|
|
|
|
* \param encoder encoder control struct to use
|
|
|
|
* \param x_cu block x position in SCU
|
|
|
|
* \param y_cu block y position in SCU
|
|
|
|
* \param depth current block depth
|
|
|
|
* \param mv_pred[2][2] 2x motion vector prediction
|
|
|
|
*/
|
2014-04-17 12:42:20 +00:00
|
|
|
void inter_get_mv_cand(const encoder_state * const encoder_state, int32_t x, int32_t y, int8_t depth, int16_t mv_cand[2][2], cu_info* cur_cu, lcu_t *lcu)
|
2014-02-21 13:00:20 +00:00
|
|
|
{
|
2013-10-11 08:59:10 +00:00
|
|
|
uint8_t candidates = 0;
|
2014-02-14 13:50:30 +00:00
|
|
|
uint8_t b_candidates = 0;
|
2013-10-11 08:59:10 +00:00
|
|
|
|
|
|
|
cu_info *b0, *b1, *b2, *a0, *a1;
|
|
|
|
b0 = b1 = b2 = a0 = a1 = NULL;
|
2014-03-03 14:08:35 +00:00
|
|
|
inter_get_spatial_merge_candidates(x, y, depth, &b0, &b1, &b2, &a0, &a1, lcu);
|
2013-09-16 13:37:24 +00:00
|
|
|
|
2014-02-14 15:13:18 +00:00
|
|
|
#define CALCULATE_SCALE(cu,tb,td) ((tb * ((0x4000 + (abs(td)>>1))/td) + 32) >> 6)
|
2014-06-05 12:54:58 +00:00
|
|
|
#define APPLY_MV_SCALING(cu, cand) {int td = encoder_state->global->poc - encoder_state->global->ref->images[(cu)->inter.mv_ref]->poc;\
|
|
|
|
int tb = encoder_state->global->poc - encoder_state->global->ref->images[cur_cu->inter.mv_ref]->poc;\
|
2014-02-14 15:13:18 +00:00
|
|
|
if (td != tb) { \
|
|
|
|
int scale = CALCULATE_SCALE(cu,tb,td); \
|
2014-02-14 13:50:30 +00:00
|
|
|
mv_cand[cand][0] = ((scale * (cu)->inter.mv[0] + 127 + (scale * (cu)->inter.mv[0] < 0)) >> 8 ); \
|
2014-02-14 15:13:18 +00:00
|
|
|
mv_cand[cand][1] = ((scale * (cu)->inter.mv[1] + 127 + (scale * (cu)->inter.mv[1] < 0)) >> 8 ); }}
|
2014-02-14 13:50:30 +00:00
|
|
|
|
2013-09-19 12:08:30 +00:00
|
|
|
// Left predictors
|
2014-02-14 13:50:30 +00:00
|
|
|
if (a0 && a0->type == CU_INTER && a0->inter.mv_ref == cur_cu->inter.mv_ref) {
|
2013-09-16 13:37:24 +00:00
|
|
|
mv_cand[candidates][0] = a0->inter.mv[0];
|
|
|
|
mv_cand[candidates][1] = a0->inter.mv[1];
|
|
|
|
candidates++;
|
2014-02-14 13:50:30 +00:00
|
|
|
} else if (a1 && a1->type == CU_INTER && a1->inter.mv_ref == cur_cu->inter.mv_ref) {
|
2013-09-16 13:37:24 +00:00
|
|
|
mv_cand[candidates][0] = a1->inter.mv[0];
|
|
|
|
mv_cand[candidates][1] = a1->inter.mv[1];
|
|
|
|
candidates++;
|
|
|
|
}
|
|
|
|
|
2014-02-14 13:50:30 +00:00
|
|
|
if(!candidates) {
|
|
|
|
// Left predictors
|
|
|
|
if (a0 && a0->type == CU_INTER) {
|
|
|
|
mv_cand[candidates][0] = a0->inter.mv[0];
|
|
|
|
mv_cand[candidates][1] = a0->inter.mv[1];
|
|
|
|
APPLY_MV_SCALING(a0, candidates);
|
|
|
|
candidates++;
|
|
|
|
} else if (a1 && a1->type == CU_INTER) {
|
|
|
|
mv_cand[candidates][0] = a1->inter.mv[0];
|
|
|
|
mv_cand[candidates][1] = a1->inter.mv[1];
|
|
|
|
APPLY_MV_SCALING(a1, candidates);
|
|
|
|
candidates++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-19 12:08:30 +00:00
|
|
|
// Top predictors
|
2014-02-14 13:50:30 +00:00
|
|
|
if (b0 && b0->type == CU_INTER && b0->inter.mv_ref == cur_cu->inter.mv_ref) {
|
2013-09-16 13:37:24 +00:00
|
|
|
mv_cand[candidates][0] = b0->inter.mv[0];
|
|
|
|
mv_cand[candidates][1] = b0->inter.mv[1];
|
2014-02-14 13:50:30 +00:00
|
|
|
b_candidates++;
|
|
|
|
} else if (b1 && b1->type == CU_INTER && b1->inter.mv_ref == cur_cu->inter.mv_ref) {
|
2013-09-16 13:37:24 +00:00
|
|
|
mv_cand[candidates][0] = b1->inter.mv[0];
|
|
|
|
mv_cand[candidates][1] = b1->inter.mv[1];
|
2014-02-21 13:00:20 +00:00
|
|
|
b_candidates++;
|
2014-02-14 13:50:30 +00:00
|
|
|
} else if(b2 && b2->type == CU_INTER && b2->inter.mv_ref == cur_cu->inter.mv_ref) {
|
2013-09-16 13:37:24 +00:00
|
|
|
mv_cand[candidates][0] = b2->inter.mv[0];
|
|
|
|
mv_cand[candidates][1] = b2->inter.mv[1];
|
2014-02-17 09:13:12 +00:00
|
|
|
b_candidates++;
|
2014-02-14 13:50:30 +00:00
|
|
|
}
|
|
|
|
candidates += b_candidates;
|
|
|
|
|
2014-02-17 15:39:40 +00:00
|
|
|
// When a1 or a0 is available, we dont check for secondary B candidates
|
2014-02-18 15:27:45 +00:00
|
|
|
if((a1 && a1->type == CU_INTER) || (a0 && a0->type == CU_INTER)) {
|
|
|
|
b_candidates = 1;
|
|
|
|
} else if(candidates != 2) {
|
|
|
|
b_candidates = 0;
|
|
|
|
}
|
2014-02-17 15:39:40 +00:00
|
|
|
|
2014-02-14 13:50:30 +00:00
|
|
|
if(!b_candidates) {
|
|
|
|
// Top predictors
|
|
|
|
if (b0 && b0->type == CU_INTER) {
|
|
|
|
mv_cand[candidates][0] = b0->inter.mv[0];
|
|
|
|
mv_cand[candidates][1] = b0->inter.mv[1];
|
|
|
|
APPLY_MV_SCALING(b0, candidates);
|
|
|
|
candidates++;
|
|
|
|
} else if (b1 && b1->type == CU_INTER) {
|
|
|
|
mv_cand[candidates][0] = b1->inter.mv[0];
|
|
|
|
mv_cand[candidates][1] = b1->inter.mv[1];
|
2014-02-17 09:13:12 +00:00
|
|
|
APPLY_MV_SCALING(b1, candidates);
|
2014-02-14 13:50:30 +00:00
|
|
|
candidates++;
|
|
|
|
} else if(b2 && b2->type == CU_INTER) {
|
|
|
|
mv_cand[candidates][0] = b2->inter.mv[0];
|
|
|
|
mv_cand[candidates][1] = b2->inter.mv[1];
|
2014-02-17 09:13:12 +00:00
|
|
|
APPLY_MV_SCALING(b2, candidates);
|
|
|
|
candidates++;
|
2014-02-14 13:50:30 +00:00
|
|
|
}
|
2013-09-16 13:37:24 +00:00
|
|
|
}
|
|
|
|
|
2013-09-19 12:08:30 +00:00
|
|
|
// Remove identical candidate
|
2013-09-18 07:15:05 +00:00
|
|
|
if(candidates == 2 && mv_cand[0][0] == mv_cand[1][0] && mv_cand[0][1] == mv_cand[1][1]) {
|
|
|
|
candidates = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if ENABLE_TEMPORAL_MVP
|
2013-10-11 13:12:04 +00:00
|
|
|
if(candidates < AMVP_MAX_NUM_CANDS) {
|
2013-09-16 13:37:24 +00:00
|
|
|
//TODO: add temporal mv predictor
|
|
|
|
}
|
2013-09-18 07:15:05 +00:00
|
|
|
#endif
|
2013-09-16 13:37:24 +00:00
|
|
|
|
2013-09-19 12:08:30 +00:00
|
|
|
// Fill with (0,0)
|
2013-10-11 13:12:04 +00:00
|
|
|
while (candidates < AMVP_MAX_NUM_CANDS) {
|
2013-09-16 13:37:24 +00:00
|
|
|
mv_cand[candidates][0] = 0;
|
|
|
|
mv_cand[candidates][1] = 0;
|
|
|
|
candidates++;
|
|
|
|
}
|
2014-02-14 13:50:30 +00:00
|
|
|
#undef CALCULATE_SCALE
|
|
|
|
#undef APPLY_MV_SCALING
|
2013-09-19 12:08:30 +00:00
|
|
|
}
|
2013-10-11 13:12:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Get merge predictions for current block
|
|
|
|
* \param encoder encoder control struct to use
|
|
|
|
* \param x_cu block x position in SCU
|
|
|
|
* \param y_cu block y position in SCU
|
|
|
|
* \param depth current block depth
|
|
|
|
* \param mv_pred[MRG_MAX_NUM_CANDS][2] MRG_MAX_NUM_CANDS motion vector prediction
|
|
|
|
*/
|
2014-03-11 07:04:17 +00:00
|
|
|
uint8_t inter_get_merge_cand(int32_t x, int32_t y, int8_t depth, int16_t mv_cand[MRG_MAX_NUM_CANDS][3], lcu_t *lcu)
|
2014-02-21 13:00:20 +00:00
|
|
|
{
|
2013-10-11 13:12:04 +00:00
|
|
|
uint8_t candidates = 0;
|
|
|
|
int8_t duplicate = 0;
|
|
|
|
|
|
|
|
cu_info *b0, *b1, *b2, *a0, *a1;
|
2014-02-14 13:50:30 +00:00
|
|
|
int8_t zero_idx = 0;
|
2013-10-11 13:12:04 +00:00
|
|
|
b0 = b1 = b2 = a0 = a1 = NULL;
|
2014-03-03 14:08:35 +00:00
|
|
|
inter_get_spatial_merge_candidates(x, y, depth, &b0, &b1, &b2, &a0, &a1, lcu);
|
2014-02-21 13:00:20 +00:00
|
|
|
|
2013-10-11 13:12:04 +00:00
|
|
|
|
2013-10-23 13:50:11 +00:00
|
|
|
#define CHECK_DUPLICATE(CU1,CU2) {duplicate = 0; if ((CU2) && (CU2)->type == CU_INTER && \
|
|
|
|
(CU1)->inter.mv[0] == (CU2)->inter.mv[0] && \
|
2014-02-18 14:59:45 +00:00
|
|
|
(CU1)->inter.mv[1] == (CU2)->inter.mv[1] && \
|
|
|
|
(CU1)->inter.mv_ref == (CU2)->inter.mv_ref) duplicate = 1; }
|
2013-10-11 13:12:04 +00:00
|
|
|
|
|
|
|
if (a1 && a1->type == CU_INTER) {
|
|
|
|
mv_cand[candidates][0] = a1->inter.mv[0];
|
|
|
|
mv_cand[candidates][1] = a1->inter.mv[1];
|
2014-02-18 14:59:45 +00:00
|
|
|
mv_cand[candidates][2] = a1->inter.mv_ref;
|
2013-10-11 13:12:04 +00:00
|
|
|
candidates++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (b1 && b1->type == CU_INTER) {
|
2014-02-18 14:59:45 +00:00
|
|
|
if(candidates) CHECK_DUPLICATE(b1, a1);
|
2013-10-11 13:12:04 +00:00
|
|
|
if(!duplicate) {
|
2014-02-18 14:59:45 +00:00
|
|
|
mv_cand[candidates][0] = b1->inter.mv[0];
|
|
|
|
mv_cand[candidates][1] = b1->inter.mv[1];
|
|
|
|
mv_cand[candidates][2] = b1->inter.mv_ref;
|
2013-10-11 13:12:04 +00:00
|
|
|
candidates++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (b0 && b0->type == CU_INTER) {
|
2014-02-18 14:59:45 +00:00
|
|
|
if(candidates) CHECK_DUPLICATE(b0,b1);
|
2013-10-11 13:12:04 +00:00
|
|
|
if(!duplicate) {
|
2014-02-18 14:59:45 +00:00
|
|
|
mv_cand[candidates][0] = b0->inter.mv[0];
|
|
|
|
mv_cand[candidates][1] = b0->inter.mv[1];
|
|
|
|
mv_cand[candidates][2] = b0->inter.mv_ref;
|
2013-10-11 13:12:04 +00:00
|
|
|
candidates++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a0 && a0->type == CU_INTER) {
|
2014-02-18 14:59:45 +00:00
|
|
|
if(candidates) CHECK_DUPLICATE(a0,a1);
|
2013-10-11 13:12:04 +00:00
|
|
|
if(!duplicate) {
|
2014-02-18 14:59:45 +00:00
|
|
|
mv_cand[candidates][0] = a0->inter.mv[0];
|
2014-02-21 13:00:20 +00:00
|
|
|
mv_cand[candidates][1] = a0->inter.mv[1];
|
2014-02-18 14:59:45 +00:00
|
|
|
mv_cand[candidates][2] = a0->inter.mv_ref;
|
2013-10-11 13:12:04 +00:00
|
|
|
candidates++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-23 13:50:11 +00:00
|
|
|
if (candidates != 4) {
|
|
|
|
if(b2 && b2->type == CU_INTER) {
|
2014-02-18 14:59:45 +00:00
|
|
|
CHECK_DUPLICATE(b2,a1);
|
2013-10-23 13:50:11 +00:00
|
|
|
if(!duplicate) {
|
2014-02-18 14:59:45 +00:00
|
|
|
CHECK_DUPLICATE(b2,b1);
|
2013-10-23 13:50:11 +00:00
|
|
|
if(!duplicate) {
|
2014-02-18 14:59:45 +00:00
|
|
|
mv_cand[candidates][0] = b2->inter.mv[0];
|
|
|
|
mv_cand[candidates][1] = b2->inter.mv[1];
|
|
|
|
mv_cand[candidates][2] = b2->inter.mv_ref;
|
2013-10-23 13:50:11 +00:00
|
|
|
candidates++;
|
|
|
|
}
|
|
|
|
}
|
2013-10-11 13:12:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLE_TEMPORAL_MVP
|
|
|
|
if(candidates < AMVP_MAX_NUM_CANDS) {
|
|
|
|
//TODO: add temporal mv predictor
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-11-05 10:49:39 +00:00
|
|
|
// Add (0,0) prediction
|
|
|
|
if (candidates != 5) {
|
2013-10-11 13:12:04 +00:00
|
|
|
mv_cand[candidates][0] = 0;
|
|
|
|
mv_cand[candidates][1] = 0;
|
2014-02-14 13:50:30 +00:00
|
|
|
mv_cand[candidates][2] = zero_idx;
|
|
|
|
zero_idx++;
|
2013-10-11 13:12:04 +00:00
|
|
|
candidates++;
|
|
|
|
}
|
2013-11-05 10:49:39 +00:00
|
|
|
|
2013-10-11 13:12:04 +00:00
|
|
|
return candidates;
|
|
|
|
}
|