Commit 83976e40 authored by Mickaël Raulet's avatar Mickaël Raulet Committed by Michael Niedermayer

hevc: C code update for new motion compensation

pretty print C
Reviewed-by: 's avatar"Ronald S. Bultje" <rsbultje@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 760a9ef4
This diff is collapsed.
...@@ -71,6 +71,9 @@ ...@@ -71,6 +71,9 @@
#define EPEL_EXTRA_BEFORE 1 #define EPEL_EXTRA_BEFORE 1
#define EPEL_EXTRA_AFTER 2 #define EPEL_EXTRA_AFTER 2
#define EPEL_EXTRA 3 #define EPEL_EXTRA 3
#define QPEL_EXTRA_BEFORE 3
#define QPEL_EXTRA_AFTER 4
#define QPEL_EXTRA 7
#define EDGE_EMU_BUFFER_STRIDE 80 #define EDGE_EMU_BUFFER_STRIDE 80
...@@ -201,6 +204,13 @@ enum InterPredIdc { ...@@ -201,6 +204,13 @@ enum InterPredIdc {
PRED_BI, PRED_BI,
}; };
enum PredFlag {
PF_INTRA = 0,
PF_L0,
PF_L1,
PF_BI,
};
enum IntraPredMode { enum IntraPredMode {
INTRA_PLANAR = 0, INTRA_PLANAR = 0,
INTRA_DC, INTRA_DC,
...@@ -626,8 +636,7 @@ typedef struct Mv { ...@@ -626,8 +636,7 @@ typedef struct Mv {
typedef struct MvField { typedef struct MvField {
Mv mv[2]; Mv mv[2];
int8_t ref_idx[2]; int8_t ref_idx[2];
int8_t pred_flag[2]; int8_t pred_flag;
uint8_t is_intra;
} MvField; } MvField;
typedef struct NeighbourAvailable { typedef struct NeighbourAvailable {
...@@ -735,6 +744,8 @@ typedef struct HEVCLocalContext { ...@@ -735,6 +744,8 @@ typedef struct HEVCLocalContext {
int end_of_tiles_y; int end_of_tiles_y;
/* +7 is for subpixel interpolation, *2 for high bit depths */ /* +7 is for subpixel interpolation, *2 for high bit depths */
DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[(MAX_PB_SIZE + 7) * EDGE_EMU_BUFFER_STRIDE * 2]; DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[(MAX_PB_SIZE + 7) * EDGE_EMU_BUFFER_STRIDE * 2];
DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer2)[(MAX_PB_SIZE + 7) * EDGE_EMU_BUFFER_STRIDE * 2];
CodingTree ct; CodingTree ct;
CodingUnit cu; CodingUnit cu;
PredictionUnit pu; PredictionUnit pu;
...@@ -973,9 +984,7 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, ...@@ -973,9 +984,7 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0,
void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase, void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase,
int log2_cb_size); int log2_cb_size);
void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
int log2_trafo_size, int log2_trafo_size);
int slice_or_tiles_up_boundary,
int slice_or_tiles_left_boundary);
int ff_hevc_cu_qp_delta_sign_flag(HEVCContext *s); int ff_hevc_cu_qp_delta_sign_flag(HEVCContext *s);
int ff_hevc_cu_qp_delta_abs(HEVCContext *s); int ff_hevc_cu_qp_delta_abs(HEVCContext *s);
void ff_hevc_hls_filter(HEVCContext *s, int x, int y); void ff_hevc_hls_filter(HEVCContext *s, int x, int y);
......
...@@ -537,7 +537,7 @@ static void cabac_init_state(HEVCContext *s) ...@@ -537,7 +537,7 @@ static void cabac_init_state(HEVCContext *s)
int init_value = init_values[init_type][i]; int init_value = init_values[init_type][i];
int m = (init_value >> 4) * 5 - 45; int m = (init_value >> 4) * 5 - 45;
int n = ((init_value & 15) << 3) - 16; int n = ((init_value & 15) << 3) - 16;
int pre = 2 * (((m * av_clip_c(s->sh.slice_qp, 0, 51)) >> 4) + n) - 127; int pre = 2 * (((m * av_clip(s->sh.slice_qp, 0, 51)) >> 4) + n) - 127;
pre ^= pre >> 31; pre ^= pre >> 31;
if (pre > 124) if (pre > 124)
...@@ -1114,7 +1114,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0, ...@@ -1114,7 +1114,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
else else
offset = s->pps->cr_qp_offset + s->sh.slice_cr_qp_offset; offset = s->pps->cr_qp_offset + s->sh.slice_cr_qp_offset;
qp_i = av_clip_c(qp_y + offset, - s->sps->qp_bd_offset, 57); qp_i = av_clip(qp_y + offset, - s->sps->qp_bd_offset, 57);
if (qp_i < 30) if (qp_i < 30)
qp = qp_i; qp = qp_i;
else if (qp_i > 43) else if (qp_i > 43)
......
This diff is collapsed.
...@@ -123,16 +123,18 @@ static int isDiffMER(HEVCContext *s, int xN, int yN, int xP, int yP) ...@@ -123,16 +123,18 @@ static int isDiffMER(HEVCContext *s, int xN, int yN, int xP, int yP)
// check if the mv's and refidx are the same between A and B // check if the mv's and refidx are the same between A and B
static int compareMVrefidx(struct MvField A, struct MvField B) static int compareMVrefidx(struct MvField A, struct MvField B)
{ {
if (A.pred_flag[0] && A.pred_flag[1] && B.pred_flag[0] && B.pred_flag[1]) int a_pf = A.pred_flag;
int b_pf = B.pred_flag;
if (a_pf == b_pf) {
if (a_pf == PF_BI) {
return MATCH(ref_idx[0]) && MATCH(mv[0].x) && MATCH(mv[0].y) && return MATCH(ref_idx[0]) && MATCH(mv[0].x) && MATCH(mv[0].y) &&
MATCH(ref_idx[1]) && MATCH(mv[1].x) && MATCH(mv[1].y); MATCH(ref_idx[1]) && MATCH(mv[1].x) && MATCH(mv[1].y);
} else if (a_pf == PF_L0) {
if (A.pred_flag[0] && !A.pred_flag[1] && B.pred_flag[0] && !B.pred_flag[1])
return MATCH(ref_idx[0]) && MATCH(mv[0].x) && MATCH(mv[0].y); return MATCH(ref_idx[0]) && MATCH(mv[0].x) && MATCH(mv[0].y);
} else if (a_pf == PF_L1) {
if (!A.pred_flag[0] && A.pred_flag[1] && !B.pred_flag[0] && B.pred_flag[1])
return MATCH(ref_idx[1]) && MATCH(mv[1].x) && MATCH(mv[1].y); return MATCH(ref_idx[1]) && MATCH(mv[1].x) && MATCH(mv[1].y);
}
}
return 0; return 0;
} }
...@@ -140,13 +142,13 @@ static av_always_inline void mv_scale(Mv *dst, Mv *src, int td, int tb) ...@@ -140,13 +142,13 @@ static av_always_inline void mv_scale(Mv *dst, Mv *src, int td, int tb)
{ {
int tx, scale_factor; int tx, scale_factor;
td = av_clip_int8_c(td); td = av_clip_int8(td);
tb = av_clip_int8_c(tb); tb = av_clip_int8(tb);
tx = (0x4000 + abs(td / 2)) / td; tx = (0x4000 + abs(td / 2)) / td;
scale_factor = av_clip_c((tb * tx + 32) >> 6, -4096, 4095); scale_factor = av_clip((tb * tx + 32) >> 6, -4096, 4095);
dst->x = av_clip_int16_c((scale_factor * src->x + 127 + dst->x = av_clip_int16((scale_factor * src->x + 127 +
(scale_factor * src->x < 0)) >> 8); (scale_factor * src->x < 0)) >> 8);
dst->y = av_clip_int16_c((scale_factor * src->y + 127 + dst->y = av_clip_int16((scale_factor * src->y + 127 +
(scale_factor * src->y < 0)) >> 8); (scale_factor * src->y < 0)) >> 8);
} }
...@@ -168,10 +170,7 @@ static int check_mvset(Mv *mvLXCol, Mv *mvCol, ...@@ -168,10 +170,7 @@ static int check_mvset(Mv *mvLXCol, Mv *mvCol,
col_poc_diff = colPic - refPicList_col[listCol].list[refidxCol]; col_poc_diff = colPic - refPicList_col[listCol].list[refidxCol];
cur_poc_diff = poc - refPicList[X].list[refIdxLx]; cur_poc_diff = poc - refPicList[X].list[refIdxLx];
if (!col_poc_diff) if (cur_lt || col_poc_diff == cur_poc_diff || !col_poc_diff) {
col_poc_diff = 1; // error resilience
if (cur_lt || col_poc_diff == cur_poc_diff) {
mvLXCol->x = mvCol->x; mvLXCol->x = mvCol->x;
mvLXCol->y = mvCol->y; mvLXCol->y = mvCol->y;
} else { } else {
...@@ -193,17 +192,14 @@ static int derive_temporal_colocated_mvs(HEVCContext *s, MvField temp_col, ...@@ -193,17 +192,14 @@ static int derive_temporal_colocated_mvs(HEVCContext *s, MvField temp_col,
{ {
RefPicList *refPicList = s->ref->refPicList; RefPicList *refPicList = s->ref->refPicList;
if (temp_col.is_intra) { if (temp_col.pred_flag == PF_INTRA)
mvLXCol->x = 0;
mvLXCol->y = 0;
return 0; return 0;
}
if (temp_col.pred_flag[0] == 0) if (!(temp_col.pred_flag & PF_L0))
return CHECK_MVSET(1); return CHECK_MVSET(1);
else if (temp_col.pred_flag[0] == 1 && temp_col.pred_flag[1] == 0) else if (temp_col.pred_flag == PF_L0)
return CHECK_MVSET(0); return CHECK_MVSET(0);
else if (temp_col.pred_flag[0] == 1 && temp_col.pred_flag[1] == 1) { else if (temp_col.pred_flag == PF_BI) {
int check_diffpicount = 0; int check_diffpicount = 0;
int i = 0; int i = 0;
for (i = 0; i < refPicList[0].nb_refs; i++) { for (i = 0; i < refPicList[0].nb_refs; i++) {
...@@ -295,7 +291,7 @@ static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0, ...@@ -295,7 +291,7 @@ static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0,
} }
#define AVAILABLE(cand, v) \ #define AVAILABLE(cand, v) \
(cand && !TAB_MVF_PU(v).is_intra) (cand && !(TAB_MVF_PU(v).pred_flag == PF_INTRA))
#define PRED_BLOCK_AVAILABLE(v) \ #define PRED_BLOCK_AVAILABLE(v) \
check_prediction_block_available(s, log2_cb_size, \ check_prediction_block_available(s, log2_cb_size, \
...@@ -458,9 +454,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0, ...@@ -458,9 +454,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
0, &mv_l1_col, 1) : 0; 0, &mv_l1_col, 1) : 0;
if (available_l0 || available_l1) { if (available_l0 || available_l1) {
mergecandlist[nb_merge_cand].is_intra = 0; mergecandlist[nb_merge_cand].pred_flag = available_l0 + (available_l1 << 1);
mergecandlist[nb_merge_cand].pred_flag[0] = available_l0;
mergecandlist[nb_merge_cand].pred_flag[1] = available_l1;
if (available_l0) { if (available_l0) {
mergecandlist[nb_merge_cand].mv[0] = mv_l0_col; mergecandlist[nb_merge_cand].mv[0] = mv_l0_col;
mergecandlist[nb_merge_cand].ref_idx[0] = 0; mergecandlist[nb_merge_cand].ref_idx[0] = 0;
...@@ -487,20 +481,18 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0, ...@@ -487,20 +481,18 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
MvField l0_cand = mergecandlist[l0_cand_idx]; MvField l0_cand = mergecandlist[l0_cand_idx];
MvField l1_cand = mergecandlist[l1_cand_idx]; MvField l1_cand = mergecandlist[l1_cand_idx];
if (l0_cand.pred_flag[0] && l1_cand.pred_flag[1] && if ((l0_cand.pred_flag & PF_L0) && (l1_cand.pred_flag & PF_L1) &&
(refPicList[0].list[l0_cand.ref_idx[0]] != (refPicList[0].list[l0_cand.ref_idx[0]] !=
refPicList[1].list[l1_cand.ref_idx[1]] || refPicList[1].list[l1_cand.ref_idx[1]] ||
l0_cand.mv[0].x != l1_cand.mv[1].x || l0_cand.mv[0].x != l1_cand.mv[1].x ||
l0_cand.mv[0].y != l1_cand.mv[1].y)) { l0_cand.mv[0].y != l1_cand.mv[1].y)) {
mergecandlist[nb_merge_cand].ref_idx[0] = l0_cand.ref_idx[0]; mergecandlist[nb_merge_cand].ref_idx[0] = l0_cand.ref_idx[0];
mergecandlist[nb_merge_cand].ref_idx[1] = l1_cand.ref_idx[1]; mergecandlist[nb_merge_cand].ref_idx[1] = l1_cand.ref_idx[1];
mergecandlist[nb_merge_cand].pred_flag[0] = 1; mergecandlist[nb_merge_cand].pred_flag = PF_BI;
mergecandlist[nb_merge_cand].pred_flag[1] = 1;
mergecandlist[nb_merge_cand].mv[0].x = l0_cand.mv[0].x; mergecandlist[nb_merge_cand].mv[0].x = l0_cand.mv[0].x;
mergecandlist[nb_merge_cand].mv[0].y = l0_cand.mv[0].y; mergecandlist[nb_merge_cand].mv[0].y = l0_cand.mv[0].y;
mergecandlist[nb_merge_cand].mv[1].x = l1_cand.mv[1].x; mergecandlist[nb_merge_cand].mv[1].x = l1_cand.mv[1].x;
mergecandlist[nb_merge_cand].mv[1].y = l1_cand.mv[1].y; mergecandlist[nb_merge_cand].mv[1].y = l1_cand.mv[1].y;
mergecandlist[nb_merge_cand].is_intra = 0;
nb_merge_cand++; nb_merge_cand++;
} }
} }
...@@ -508,13 +500,11 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0, ...@@ -508,13 +500,11 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
// append Zero motion vector candidates // append Zero motion vector candidates
while (nb_merge_cand < s->sh.max_num_merge_cand) { while (nb_merge_cand < s->sh.max_num_merge_cand) {
mergecandlist[nb_merge_cand].pred_flag[0] = 1; mergecandlist[nb_merge_cand].pred_flag = PF_L0 + ((s->sh.slice_type == B_SLICE) << 1);
mergecandlist[nb_merge_cand].pred_flag[1] = s->sh.slice_type == B_SLICE;
mergecandlist[nb_merge_cand].mv[0].x = 0; mergecandlist[nb_merge_cand].mv[0].x = 0;
mergecandlist[nb_merge_cand].mv[0].y = 0; mergecandlist[nb_merge_cand].mv[0].y = 0;
mergecandlist[nb_merge_cand].mv[1].x = 0; mergecandlist[nb_merge_cand].mv[1].x = 0;
mergecandlist[nb_merge_cand].mv[1].y = 0; mergecandlist[nb_merge_cand].mv[1].y = 0;
mergecandlist[nb_merge_cand].is_intra = 0;
mergecandlist[nb_merge_cand].ref_idx[0] = zero_idx < nb_refs ? zero_idx : 0; mergecandlist[nb_merge_cand].ref_idx[0] = zero_idx < nb_refs ? zero_idx : 0;
mergecandlist[nb_merge_cand].ref_idx[1] = zero_idx < nb_refs ? zero_idx : 0; mergecandlist[nb_merge_cand].ref_idx[1] = zero_idx < nb_refs ? zero_idx : 0;
...@@ -550,11 +540,9 @@ void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0, int nPbW, ...@@ -550,11 +540,9 @@ void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0, int nPbW,
derive_spatial_merge_candidates(s, x0, y0, nPbW, nPbH, log2_cb_size, derive_spatial_merge_candidates(s, x0, y0, nPbW, nPbH, log2_cb_size,
singleMCLFlag, part_idx, mergecand_list); singleMCLFlag, part_idx, mergecand_list);
if (mergecand_list[merge_idx].pred_flag[0] == 1 && if (mergecand_list[merge_idx].pred_flag == PF_BI &&
mergecand_list[merge_idx].pred_flag[1] == 1 &&
(nPbW2 + nPbH2) == 12) { (nPbW2 + nPbH2) == 12) {
mergecand_list[merge_idx].ref_idx[1] = -1; mergecand_list[merge_idx].pred_flag = PF_L0;
mergecand_list[merge_idx].pred_flag[1] = 0;
} }
*mv = mergecand_list[merge_idx]; *mv = mergecand_list[merge_idx];
...@@ -585,7 +573,7 @@ static int mv_mp_mode_mx(HEVCContext *s, int x, int y, int pred_flag_index, ...@@ -585,7 +573,7 @@ static int mv_mp_mode_mx(HEVCContext *s, int x, int y, int pred_flag_index,
RefPicList *refPicList = s->ref->refPicList; RefPicList *refPicList = s->ref->refPicList;
if (TAB_MVF(x, y).pred_flag[pred_flag_index] == 1 && if (((TAB_MVF(x, y).pred_flag) & (1 << pred_flag_index)) &&
refPicList[pred_flag_index].list[TAB_MVF(x, y).ref_idx[pred_flag_index]] == refPicList[ref_idx_curr].list[ref_idx]) { refPicList[pred_flag_index].list[TAB_MVF(x, y).ref_idx[pred_flag_index]] == refPicList[ref_idx_curr].list[ref_idx]) {
*mv = TAB_MVF(x, y).mv[pred_flag_index]; *mv = TAB_MVF(x, y).mv[pred_flag_index];
return 1; return 1;
...@@ -600,19 +588,21 @@ static int mv_mp_mode_mx_lt(HEVCContext *s, int x, int y, int pred_flag_index, ...@@ -600,19 +588,21 @@ static int mv_mp_mode_mx_lt(HEVCContext *s, int x, int y, int pred_flag_index,
int min_pu_width = s->sps->min_pu_width; int min_pu_width = s->sps->min_pu_width;
RefPicList *refPicList = s->ref->refPicList; RefPicList *refPicList = s->ref->refPicList;
if ((TAB_MVF(x, y).pred_flag) & (1 << pred_flag_index)) {
int currIsLongTerm = refPicList[ref_idx_curr].isLongTerm[ref_idx]; int currIsLongTerm = refPicList[ref_idx_curr].isLongTerm[ref_idx];
int colIsLongTerm = int colIsLongTerm =
refPicList[pred_flag_index].isLongTerm[(TAB_MVF(x, y).ref_idx[pred_flag_index])]; refPicList[pred_flag_index].isLongTerm[(TAB_MVF(x, y).ref_idx[pred_flag_index])];
if (TAB_MVF(x, y).pred_flag[pred_flag_index] && if (colIsLongTerm == currIsLongTerm) {
colIsLongTerm == currIsLongTerm) {
*mv = TAB_MVF(x, y).mv[pred_flag_index]; *mv = TAB_MVF(x, y).mv[pred_flag_index];
if (!currIsLongTerm) if (!currIsLongTerm)
dist_scale(s, mv, min_pu_width, x, y, dist_scale(s, mv, min_pu_width, x, y,
pred_flag_index, ref_idx_curr, ref_idx); pred_flag_index, ref_idx_curr, ref_idx);
return 1; return 1;
} }
}
return 0; return 0;
} }
...@@ -657,8 +647,8 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW, ...@@ -657,8 +647,8 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
int xB2_pu = 0, yB2_pu = 0; int xB2_pu = 0, yB2_pu = 0;
int is_available_b2 = 0; int is_available_b2 = 0;
Mv mvpcand_list[2] = { { 0 } }; Mv mvpcand_list[2] = { { 0 } };
Mv mxA = { 0 }; Mv mxA;
Mv mxB = { 0 }; Mv mxB;
int ref_idx_curr = 0; int ref_idx_curr = 0;
int ref_idx = 0; int ref_idx = 0;
int pred_flag_index_l0; int pred_flag_index_l0;
...@@ -812,10 +802,5 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW, ...@@ -812,10 +802,5 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
mvpcand_list[numMVPCandLX++] = mv_col; mvpcand_list[numMVPCandLX++] = mv_col;
} }
// insert zero motion vectors when the number of available candidates are less than 2 mv->mv[LX] = mvpcand_list[mvp_lx_flag];
while (numMVPCandLX < 2)
mvpcand_list[numMVPCandLX++] = (Mv){ 0, 0 };
mv->mv[LX].x = mvpcand_list[mvp_lx_flag].x;
mv->mv[LX].y = mvpcand_list[mvp_lx_flag].y;
} }
...@@ -89,14 +89,20 @@ static const int8_t transform[32][32] = { ...@@ -89,14 +89,20 @@ static const int8_t transform[32][32] = {
90, -90, 88, -85, 82, -78, 73, -67, 61, -54, 46, -38, 31, -22, 13, -4 }, 90, -90, 88, -85, 82, -78, 73, -67, 61, -54, 46, -38, 31, -22, 13, -4 },
}; };
DECLARE_ALIGNED(16, const int8_t, ff_hevc_epel_filters[7][16]) = { DECLARE_ALIGNED(16, const int8_t, ff_hevc_epel_filters[7][4]) = {
{ -2, 58, 10, -2, -2, 58, 10, -2, -2, 58, 10, -2, -2, 58, 10, -2 }, { -2, 58, 10, -2},
{ -4, 54, 16, -2, -4, 54, 16, -2, -4, 54, 16, -2, -4, 54, 16, -2 }, { -4, 54, 16, -2},
{ -6, 46, 28, -4, -6, 46, 28, -4, -6, 46, 28, -4, -6, 46, 28, -4 }, { -6, 46, 28, -4},
{ -4, 36, 36, -4, -4, 36, 36, -4, -4, 36, 36, -4, -4, 36, 36, -4 }, { -4, 36, 36, -4},
{ -4, 28, 46, -6, -4, 28, 46, -6, -4, 28, 46, -6, -4, 28, 46, -6 }, { -4, 28, 46, -6},
{ -2, 16, 54, -4, -2, 16, 54, -4, -2, 16, 54, -4, -2, 16, 54, -4 }, { -2, 16, 54, -4},
{ -2, 10, 58, -2, -2, 10, 58, -2, -2, 10, 58, -2, -2, 10, 58, -2 }, { -2, 10, 58, -2},
};
DECLARE_ALIGNED(16, const int8_t, ff_hevc_qpel_filters[3][16]) = {
{ -1, 4,-10, 58, 17, -5, 1, 0, -1, 4,-10, 58, 17, -5, 1, 0},
{ -1, 4,-11, 40, 40,-11, 4, -1, -1, 4,-11, 40, 40,-11, 4, -1},
{ 0, 1, -5, 17, 58,-10, 4, -1, 0, 1, -5, 17, 58,-10, 4, -1}
}; };
#define BIT_DEPTH 8 #define BIT_DEPTH 8
...@@ -116,6 +122,71 @@ void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth) ...@@ -116,6 +122,71 @@ void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
#undef FUNC #undef FUNC
#define FUNC(a, depth) a ## _ ## depth #define FUNC(a, depth) a ## _ ## depth
#undef PEL_FUNC
#define PEL_FUNC(dst1, idx1, idx2, a, depth) \
for(i = 0 ; i < 10 ; i++) \
{ \
hevcdsp->dst1[i][idx1][idx2] = a ## _ ## depth; \
}
#undef EPEL_FUNCS
#define EPEL_FUNCS(depth) \
PEL_FUNC(put_hevc_epel, 0, 0, put_hevc_pel_pixels, depth); \
PEL_FUNC(put_hevc_epel, 0, 1, put_hevc_epel_h, depth); \
PEL_FUNC(put_hevc_epel, 1, 0, put_hevc_epel_v, depth); \
PEL_FUNC(put_hevc_epel, 1, 1, put_hevc_epel_hv, depth)
#undef EPEL_UNI_FUNCS
#define EPEL_UNI_FUNCS(depth) \
PEL_FUNC(put_hevc_epel_uni, 0, 0, put_hevc_pel_uni_pixels, depth); \
PEL_FUNC(put_hevc_epel_uni, 0, 1, put_hevc_epel_uni_h, depth); \
PEL_FUNC(put_hevc_epel_uni, 1, 0, put_hevc_epel_uni_v, depth); \
PEL_FUNC(put_hevc_epel_uni, 1, 1, put_hevc_epel_uni_hv, depth); \
PEL_FUNC(put_hevc_epel_uni_w, 0, 0, put_hevc_pel_uni_w_pixels, depth); \
PEL_FUNC(put_hevc_epel_uni_w, 0, 1, put_hevc_epel_uni_w_h, depth); \
PEL_FUNC(put_hevc_epel_uni_w, 1, 0, put_hevc_epel_uni_w_v, depth); \
PEL_FUNC(put_hevc_epel_uni_w, 1, 1, put_hevc_epel_uni_w_hv, depth)
#undef EPEL_BI_FUNCS
#define EPEL_BI_FUNCS(depth) \
PEL_FUNC(put_hevc_epel_bi, 0, 0, put_hevc_pel_bi_pixels, depth); \
PEL_FUNC(put_hevc_epel_bi, 0, 1, put_hevc_epel_bi_h, depth); \
PEL_FUNC(put_hevc_epel_bi, 1, 0, put_hevc_epel_bi_v, depth); \
PEL_FUNC(put_hevc_epel_bi, 1, 1, put_hevc_epel_bi_hv, depth); \
PEL_FUNC(put_hevc_epel_bi_w, 0, 0, put_hevc_pel_bi_w_pixels, depth); \
PEL_FUNC(put_hevc_epel_bi_w, 0, 1, put_hevc_epel_bi_w_h, depth); \
PEL_FUNC(put_hevc_epel_bi_w, 1, 0, put_hevc_epel_bi_w_v, depth); \
PEL_FUNC(put_hevc_epel_bi_w, 1, 1, put_hevc_epel_bi_w_hv, depth)
#undef QPEL_FUNCS
#define QPEL_FUNCS(depth) \
PEL_FUNC(put_hevc_qpel, 0, 0, put_hevc_pel_pixels, depth); \
PEL_FUNC(put_hevc_qpel, 0, 1, put_hevc_qpel_h, depth); \
PEL_FUNC(put_hevc_qpel, 1, 0, put_hevc_qpel_v, depth); \
PEL_FUNC(put_hevc_qpel, 1, 1, put_hevc_qpel_hv, depth)
#undef QPEL_UNI_FUNCS
#define QPEL_UNI_FUNCS(depth) \
PEL_FUNC(put_hevc_qpel_uni, 0, 0, put_hevc_pel_uni_pixels, depth); \
PEL_FUNC(put_hevc_qpel_uni, 0, 1, put_hevc_qpel_uni_h, depth); \
PEL_FUNC(put_hevc_qpel_uni, 1, 0, put_hevc_qpel_uni_v, depth); \
PEL_FUNC(put_hevc_qpel_uni, 1, 1, put_hevc_qpel_uni_hv, depth); \
PEL_FUNC(put_hevc_qpel_uni_w, 0, 0, put_hevc_pel_uni_w_pixels, depth); \
PEL_FUNC(put_hevc_qpel_uni_w, 0, 1, put_hevc_qpel_uni_w_h, depth); \
PEL_FUNC(put_hevc_qpel_uni_w, 1, 0, put_hevc_qpel_uni_w_v, depth); \
PEL_FUNC(put_hevc_qpel_uni_w, 1, 1, put_hevc_qpel_uni_w_hv, depth)
#undef QPEL_BI_FUNCS
#define QPEL_BI_FUNCS(depth) \
PEL_FUNC(put_hevc_qpel_bi, 0, 0, put_hevc_pel_bi_pixels, depth); \
PEL_FUNC(put_hevc_qpel_bi, 0, 1, put_hevc_qpel_bi_h, depth); \
PEL_FUNC(put_hevc_qpel_bi, 1, 0, put_hevc_qpel_bi_v, depth); \
PEL_FUNC(put_hevc_qpel_bi, 1, 1, put_hevc_qpel_bi_hv, depth); \
PEL_FUNC(put_hevc_qpel_bi_w, 0, 0, put_hevc_pel_bi_w_pixels, depth); \
PEL_FUNC(put_hevc_qpel_bi_w, 0, 1, put_hevc_qpel_bi_w_h, depth); \
PEL_FUNC(put_hevc_qpel_bi_w, 1, 0, put_hevc_qpel_bi_w_v, depth); \
PEL_FUNC(put_hevc_qpel_bi_w, 1, 1, put_hevc_qpel_bi_w_hv, depth)
#define HEVC_DSP(depth) \ #define HEVC_DSP(depth) \
hevcdsp->put_pcm = FUNC(put_pcm, depth); \ hevcdsp->put_pcm = FUNC(put_pcm, depth); \
hevcdsp->transquant_bypass[0] = FUNC(transquant_bypass4x4, depth); \ hevcdsp->transquant_bypass[0] = FUNC(transquant_bypass4x4, depth); \
...@@ -139,33 +210,12 @@ void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth) ...@@ -139,33 +210,12 @@ void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
hevcdsp->sao_edge_filter[2] = FUNC(sao_edge_filter_2, depth); \ hevcdsp->sao_edge_filter[2] = FUNC(sao_edge_filter_2, depth); \
hevcdsp->sao_edge_filter[3] = FUNC(sao_edge_filter_3, depth); \ hevcdsp->sao_edge_filter[3] = FUNC(sao_edge_filter_3, depth); \
\ \
hevcdsp->put_hevc_qpel[0][0] = FUNC(put_hevc_qpel_pixels, depth); \ QPEL_FUNCS(depth); \
hevcdsp->put_hevc_qpel[0][1] = FUNC(put_hevc_qpel_h1, depth); \ QPEL_UNI_FUNCS(depth); \
hevcdsp->put_hevc_qpel[0][2] = FUNC(put_hevc_qpel_h2, depth); \ QPEL_BI_FUNCS(depth); \
hevcdsp->put_hevc_qpel[0][3] = FUNC(put_hevc_qpel_h3, depth); \ EPEL_FUNCS(depth); \
hevcdsp->put_hevc_qpel[1][0] = FUNC(put_hevc_qpel_v1, depth); \ EPEL_UNI_FUNCS(depth); \
hevcdsp->put_hevc_qpel[1][1] = FUNC(put_hevc_qpel_h1v1, depth); \ EPEL_BI_FUNCS(depth); \
hevcdsp->put_hevc_qpel[1][2] = FUNC(put_hevc_qpel_h2v1, depth); \
hevcdsp->put_hevc_qpel[1][3] = FUNC(put_hevc_qpel_h3v1, depth); \
hevcdsp->put_hevc_qpel[2][0] = FUNC(put_hevc_qpel_v2, depth); \
hevcdsp->put_hevc_qpel[2][1] = FUNC(put_hevc_qpel_h1v2, depth); \
hevcdsp->put_hevc_qpel[2][2] = FUNC(put_hevc_qpel_h2v2, depth); \
hevcdsp->put_hevc_qpel[2][3] = FUNC(put_hevc_qpel_h3v2, depth); \
hevcdsp->put_hevc_qpel[3][0] = FUNC(put_hevc_qpel_v3, depth); \
hevcdsp->put_hevc_qpel[3][1] = FUNC(put_hevc_qpel_h1v3, depth); \
hevcdsp->put_hevc_qpel[3][2] = FUNC(put_hevc_qpel_h2v3, depth); \
hevcdsp->put_hevc_qpel[3][3] = FUNC(put_hevc_qpel_h3v3, depth); \
\
hevcdsp->put_hevc_epel[0][0] = FUNC(put_hevc_epel_pixels, depth); \
hevcdsp->put_hevc_epel[0][1] = FUNC(put_hevc_epel_h, depth); \
hevcdsp->put_hevc_epel[1][0] = FUNC(put_hevc_epel_v, depth); \
hevcdsp->put_hevc_epel[1][1] = FUNC(put_hevc_epel_hv, depth); \
\
hevcdsp->put_unweighted_pred = FUNC(put_unweighted_pred, depth); \
hevcdsp->put_weighted_pred_avg = FUNC(put_weighted_pred_avg, depth); \
\
hevcdsp->weighted_pred = FUNC(weighted_pred, depth); \
hevcdsp->weighted_pred_avg = FUNC(weighted_pred_avg, depth); \
\ \
hevcdsp->hevc_h_loop_filter_luma = FUNC(hevc_h_loop_filter_luma, depth); \ hevcdsp->hevc_h_loop_filter_luma = FUNC(hevc_h_loop_filter_luma, depth); \
hevcdsp->hevc_v_loop_filter_luma = FUNC(hevc_v_loop_filter_luma, depth); \ hevcdsp->hevc_v_loop_filter_luma = FUNC(hevc_v_loop_filter_luma, depth); \
...@@ -175,6 +225,7 @@ void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth) ...@@ -175,6 +225,7 @@ void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
hevcdsp->hevc_v_loop_filter_luma_c = FUNC(hevc_v_loop_filter_luma, depth); \ hevcdsp->hevc_v_loop_filter_luma_c = FUNC(hevc_v_loop_filter_luma, depth); \
hevcdsp->hevc_h_loop_filter_chroma_c = FUNC(hevc_h_loop_filter_chroma, depth); \ hevcdsp->hevc_h_loop_filter_chroma_c = FUNC(hevc_h_loop_filter_chroma, depth); \
hevcdsp->hevc_v_loop_filter_chroma_c = FUNC(hevc_v_loop_filter_chroma, depth); hevcdsp->hevc_v_loop_filter_chroma_c = FUNC(hevc_v_loop_filter_chroma, depth);
int i = 0;
switch (bit_depth) { switch (bit_depth) {
case 9: case 9:
......
...@@ -58,25 +58,34 @@ typedef struct HEVCDSPContext { ...@@ -58,25 +58,34 @@ typedef struct HEVCDSPContext {
int height, int c_idx, uint8_t vert_edge, int height, int c_idx, uint8_t vert_edge,
uint8_t horiz_edge, uint8_t diag_edge); uint8_t horiz_edge, uint8_t diag_edge);
void (*put_hevc_qpel[4][4])(int16_t *dst, ptrdiff_t dststride, uint8_t *src, void (*put_hevc_qpel[10][2][2])(int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
ptrdiff_t srcstride, int width, int height, int height, intptr_t mx, intptr_t my, int width);
int16_t *mcbuffer); void (*put_hevc_qpel_uni[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
void (*put_hevc_epel[2][2])(int16_t *dst, ptrdiff_t dststride, uint8_t *src, int height, intptr_t mx, intptr_t my, int width);
ptrdiff_t srcstride, int width, int height, void (*put_hevc_qpel_uni_w[10][2][2])(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
int mx, int my, int16_t *mcbuffer); int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width);
void (*put_unweighted_pred)(uint8_t *dst, ptrdiff_t dststride, int16_t *src, void (*put_hevc_qpel_bi[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
ptrdiff_t srcstride, int width, int height); int16_t *src2, ptrdiff_t src2stride,
void (*put_weighted_pred_avg)(uint8_t *dst, ptrdiff_t dststride, int height, intptr_t mx, intptr_t my, int width);
int16_t *src1, int16_t *src2, void (*put_hevc_qpel_bi_w[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
ptrdiff_t srcstride, int width, int height); int16_t *src2, ptrdiff_t src2stride,
void (*weighted_pred)(uint8_t denom, int16_t wlxFlag, int16_t olxFlag, int height, int denom, int wx0, int wx1,
uint8_t *dst, ptrdiff_t dststride, int16_t *src, int ox0, int ox1, intptr_t mx, intptr_t my, int width);
ptrdiff_t srcstride, int width, int height); void (*put_hevc_epel[10][2][2])(int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
void (*weighted_pred_avg)(uint8_t denom, int16_t wl0Flag, int16_t wl1Flag, int height, intptr_t mx, intptr_t my, int width);
int16_t ol0Flag, int16_t ol1Flag, uint8_t *dst,
ptrdiff_t dststride, int16_t *src1, int16_t *src2, void (*put_hevc_epel_uni[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
ptrdiff_t srcstride, int width, int height); int height, intptr_t mx, intptr_t my, int width);
void (*put_hevc_epel_uni_w[10][2][2])(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width);
void (*put_hevc_epel_bi[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
int16_t *src2, ptrdiff_t src2stride,
int height, intptr_t mx, intptr_t my, int width);
void (*put_hevc_epel_bi_w[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
int16_t *src2, ptrdiff_t src2stride,
int height, int denom, int wx0, int ox0, int wx1,
int ox1, intptr_t mx, intptr_t my, int width);
void (*hevc_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride, void (*hevc_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
int *beta, int *tc, int *beta, int *tc,
...@@ -104,6 +113,8 @@ typedef struct HEVCDSPContext { ...@@ -104,6 +113,8 @@ typedef struct HEVCDSPContext {
void ff_hevc_dsp_init(HEVCDSPContext *hpc, int bit_depth); void ff_hevc_dsp_init(HEVCDSPContext *hpc, int bit_depth);
extern const int8_t ff_hevc_epel_filters[7][16]; extern const int8_t ff_hevc_epel_filters[7][4];
extern const int8_t ff_hevc_qpel_filters[3][16];
#endif /* AVCODEC_HEVCDSP_H */ #endif /* AVCODEC_HEVCDSP_H */
This diff is collapsed.
...@@ -36,7 +36,7 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int ...@@ -36,7 +36,7 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
#define MVF_PU(x, y) \ #define MVF_PU(x, y) \
MVF(PU(x0 + ((x) << hshift)), PU(y0 + ((y) << vshift))) MVF(PU(x0 + ((x) << hshift)), PU(y0 + ((y) << vshift)))
#define IS_INTRA(x, y) \ #define IS_INTRA(x, y) \
MVF_PU(x, y).is_intra (MVF_PU(x, y).pred_flag == PF_INTRA)
#define MIN_TB_ADDR_ZS(x, y) \ #define MIN_TB_ADDR_ZS(x, y) \
s->pps->min_tb_addr_zs[(y) * s->sps->min_tb_width + (x)] s->pps->min_tb_addr_zs[(y) * s->sps->min_tb_width + (x)]
#define EXTEND_LEFT(ptr, start, length) \ #define EXTEND_LEFT(ptr, start, length) \
...@@ -120,7 +120,7 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int ...@@ -120,7 +120,7 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
int max = FFMIN(size_in_luma_pu, s->sps->min_pu_height - y_bottom_pu); int max = FFMIN(size_in_luma_pu, s->sps->min_pu_height - y_bottom_pu);
cand_bottom_left = 0; cand_bottom_left = 0;
for (i = 0; i < max; i++) for (i = 0; i < max; i++)
cand_bottom_left |= MVF(x_left_pu, y_bottom_pu + i).is_intra; cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA);
} }
if (cand_left == 1 && on_pu_edge_x) { if (cand_left == 1 && on_pu_edge_x) {
int x_left_pu = PU(x0 - 1); int x_left_pu = PU(x0 - 1);
...@@ -128,12 +128,12 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int ...@@ -128,12 +128,12 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
int max = FFMIN(size_in_luma_pu, s->sps->min_pu_height - y_left_pu); int max = FFMIN(size_in_luma_pu, s->sps->min_pu_height - y_left_pu);
cand_left = 0; cand_left = 0;
for (i = 0; i < max; i++) for (i = 0; i < max; i++)
cand_left |= MVF(x_left_pu, y_left_pu + i).is_intra; cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA);
} }
if (cand_up_left == 1) { if (cand_up_left == 1) {
int x_left_pu = PU(x0 - 1); int x_left_pu = PU(x0 - 1);
int y_top_pu = PU(y0 - 1); int y_top_pu = PU(y0 - 1);
cand_up_left = MVF(x_left_pu, y_top_pu).is_intra; cand_up_left = MVF(x_left_pu, y_top_pu).pred_flag == PF_INTRA;
} }
if (cand_up == 1 && on_pu_edge_y) { if (cand_up == 1 && on_pu_edge_y) {
int x_top_pu = PU(x0); int x_top_pu = PU(x0);
...@@ -141,7 +141,7 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int ...@@ -141,7 +141,7 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
int max = FFMIN(size_in_luma_pu, s->sps->min_pu_width - x_top_pu); int max = FFMIN(size_in_luma_pu, s->sps->min_pu_width - x_top_pu);
cand_up = 0; cand_up = 0;
for (i = 0; i < max; i++) for (i = 0; i < max; i++)
cand_up |= MVF(x_top_pu + i, y_top_pu).is_intra; cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA);
} }
if (cand_up_right == 1 && on_pu_edge_y) { if (cand_up_right == 1 && on_pu_edge_y) {
int y_top_pu = PU(y0 - 1); int y_top_pu = PU(y0 - 1);
...@@ -149,7 +149,7 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int ...@@ -149,7 +149,7 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
int max = FFMIN(size_in_luma_pu, s->sps->min_pu_width - x_right_pu); int max = FFMIN(size_in_luma_pu, s->sps->min_pu_width - x_right_pu);
cand_up_right = 0; cand_up_right = 0;
for (i = 0; i < max; i++) for (i = 0; i < max; i++)
cand_up_right |= MVF(x_right_pu + i, y_top_pu).is_intra; cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA);
} }
for (i = 0; i < 2 * MAX_TB_SIZE; i++) { for (i = 0; i < 2 * MAX_TB_SIZE; i++) {
left[i] = 128; left[i] = 128;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment