mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-09 02:50:06 +08:00
[h265d_parser] remove pps ctb_addr map process,no need mpp_hevc_slice_rpl process
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@735 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -1356,7 +1356,7 @@ static RK_S32 parser_nal_unit(HEVCContext *s, const RK_U8 *nal, int length)
|
|||||||
|
|
||||||
if (!s->sh.dependent_slice_segment_flag &&
|
if (!s->sh.dependent_slice_segment_flag &&
|
||||||
s->sh.slice_type != I_SLICE) {
|
s->sh.slice_type != I_SLICE) {
|
||||||
ret = mpp_hevc_slice_rpl(s);
|
// ret = mpp_hevc_slice_rpl(s);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
mpp_log("Error constructing the reference lists for the current slice.\n");
|
mpp_log("Error constructing the reference lists for the current slice.\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
@@ -1805,7 +1805,6 @@ MPP_RET h265d_parse(void *ctx, HalDecTask *task)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
s->nb_frame++;
|
s->nb_frame++;
|
||||||
|
|
||||||
if (s->is_decoded) {
|
if (s->is_decoded) {
|
||||||
h265d_dbg(H265D_DBG_GLOBAL, "Decoded frame with POC %d.\n", s->poc);
|
h265d_dbg(H265D_DBG_GLOBAL, "Decoded frame with POC %d.\n", s->poc);
|
||||||
s->is_decoded = 0;
|
s->is_decoded = 0;
|
||||||
|
@@ -429,16 +429,7 @@ typedef struct HEVCPPS {
|
|||||||
// Inferred parameters
|
// Inferred parameters
|
||||||
RK_U32 *column_width; ///< ColumnWidth
|
RK_U32 *column_width; ///< ColumnWidth
|
||||||
RK_U32 *row_height; ///< RowHeight
|
RK_U32 *row_height; ///< RowHeight
|
||||||
RK_U32 *col_bd; ///< ColBd
|
|
||||||
RK_U32 *row_bd; ///< RowBd
|
|
||||||
RK_S32 *col_idxX;
|
|
||||||
|
|
||||||
RK_S32 *ctb_addr_rs_to_ts; ///< CtbAddrRSToTS
|
|
||||||
RK_S32 *ctb_addr_ts_to_rs; ///< CtbAddrTSToRS
|
|
||||||
RK_S32 *tile_id; ///< TileId
|
|
||||||
RK_S32 *tile_pos_rs; ///< TilePosRS
|
|
||||||
RK_S32 *min_cb_addr_zs; ///< MinCbAddrZS
|
|
||||||
RK_S32 *min_tb_addr_zs; ///< MinTbAddrZS
|
|
||||||
} HEVCPPS;
|
} HEVCPPS;
|
||||||
|
|
||||||
typedef struct SliceHeader {
|
typedef struct SliceHeader {
|
||||||
|
@@ -1846,15 +1846,6 @@ void mpp_hevc_pps_free(RK_U8 *data)
|
|||||||
if (pps != NULL) {
|
if (pps != NULL) {
|
||||||
mpp_free(pps->column_width);
|
mpp_free(pps->column_width);
|
||||||
mpp_free(pps->row_height);
|
mpp_free(pps->row_height);
|
||||||
mpp_free(pps->col_bd);
|
|
||||||
mpp_free(pps->row_bd);
|
|
||||||
mpp_free(pps->col_idxX);
|
|
||||||
mpp_free(pps->ctb_addr_rs_to_ts);
|
|
||||||
mpp_free(pps->ctb_addr_ts_to_rs);
|
|
||||||
mpp_free(pps->tile_pos_rs);
|
|
||||||
mpp_free(pps->tile_id);
|
|
||||||
mpp_free(pps->min_cb_addr_zs);
|
|
||||||
mpp_free(pps->min_tb_addr_zs);
|
|
||||||
mpp_free(pps);
|
mpp_free(pps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1864,8 +1855,7 @@ int mpp_hevc_decode_nal_pps(HEVCContext *s)
|
|||||||
|
|
||||||
BitReadCtx_t *gb = &s->HEVClc->gb;
|
BitReadCtx_t *gb = &s->HEVClc->gb;
|
||||||
HEVCSPS *sps = NULL;
|
HEVCSPS *sps = NULL;
|
||||||
RK_S32 pic_area_in_ctbs, pic_area_in_min_cbs, pic_area_in_min_tbs;
|
RK_S32 i;
|
||||||
RK_S32 i, j, x, y, ctb_addr_rs, tile_id;
|
|
||||||
RK_S32 ret = 0;
|
RK_S32 ret = 0;
|
||||||
RK_S32 pps_id = 0;
|
RK_S32 pps_id = 0;
|
||||||
|
|
||||||
@@ -2079,14 +2069,6 @@ int mpp_hevc_decode_nal_pps(HEVCContext *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inferred parameters
|
// Inferred parameters
|
||||||
pps->col_bd = mpp_malloc(RK_U32, (pps->num_tile_columns + 1));
|
|
||||||
pps->row_bd = mpp_malloc(RK_U32, (pps->num_tile_rows + 1));
|
|
||||||
pps->col_idxX = mpp_malloc(RK_S32, sps->ctb_width);
|
|
||||||
if (!pps->col_bd || !pps->row_bd || !pps->col_idxX) {
|
|
||||||
ret = MPP_ERR_NOMEM;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pps->uniform_spacing_flag) {
|
if (pps->uniform_spacing_flag) {
|
||||||
if (!pps->column_width) {
|
if (!pps->column_width) {
|
||||||
pps->column_width = mpp_malloc(RK_U32, pps->num_tile_columns );
|
pps->column_width = mpp_malloc(RK_U32, pps->num_tile_columns );
|
||||||
@@ -2108,87 +2090,6 @@ int mpp_hevc_decode_nal_pps(HEVCContext *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pps->col_bd[0] = 0;
|
|
||||||
for (i = 0; i < pps->num_tile_columns; i++)
|
|
||||||
pps->col_bd[i + 1] = pps->col_bd[i] + pps->column_width[i];
|
|
||||||
|
|
||||||
pps->row_bd[0] = 0;
|
|
||||||
for (i = 0; i < pps->num_tile_rows; i++)
|
|
||||||
pps->row_bd[i + 1] = pps->row_bd[i] + pps->row_height[i];
|
|
||||||
|
|
||||||
for (i = 0, j = 0; i < sps->ctb_width; i++) {
|
|
||||||
if ((RK_U32)i > pps->col_bd[j])
|
|
||||||
j++;
|
|
||||||
pps->col_idxX[i] = j;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 6.5
|
|
||||||
*/
|
|
||||||
pic_area_in_ctbs = sps->ctb_width * sps->ctb_height;
|
|
||||||
pic_area_in_min_cbs = sps->min_cb_width * sps->min_cb_height;
|
|
||||||
pic_area_in_min_tbs = sps->min_tb_width * sps->min_tb_height;
|
|
||||||
|
|
||||||
pps->ctb_addr_rs_to_ts = mpp_malloc(RK_S32, pic_area_in_ctbs);
|
|
||||||
pps->ctb_addr_ts_to_rs = mpp_malloc(RK_S32, pic_area_in_ctbs);
|
|
||||||
pps->tile_id = mpp_malloc(RK_S32, pic_area_in_ctbs );
|
|
||||||
pps->min_cb_addr_zs = mpp_malloc(RK_S32, pic_area_in_min_cbs);
|
|
||||||
pps->min_tb_addr_zs = mpp_malloc(RK_S32, pic_area_in_min_tbs);
|
|
||||||
if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs ||
|
|
||||||
!pps->tile_id || !pps->min_cb_addr_zs || !pps->min_tb_addr_zs) {
|
|
||||||
ret = MPP_ERR_NOMEM;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) {
|
|
||||||
RK_U32 tb_x = ctb_addr_rs % sps->ctb_width;
|
|
||||||
RK_U32 tb_y = ctb_addr_rs / sps->ctb_width;
|
|
||||||
RK_S32 tile_x = 0;
|
|
||||||
RK_S32 tile_y = 0;
|
|
||||||
int val = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < pps->num_tile_columns; i++) {
|
|
||||||
if (tb_x < pps->col_bd[i + 1]) {
|
|
||||||
tile_x = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < pps->num_tile_rows; i++) {
|
|
||||||
if (tb_y < pps->row_bd[i + 1]) {
|
|
||||||
tile_y = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < tile_x; i++)
|
|
||||||
val += pps->row_height[tile_y] * pps->column_width[i];
|
|
||||||
for (i = 0; i < tile_y; i++)
|
|
||||||
val += sps->ctb_width * pps->row_height[i];
|
|
||||||
|
|
||||||
val += (tb_y - pps->row_bd[tile_y]) * pps->column_width[tile_x] +
|
|
||||||
tb_x - pps->col_bd[tile_x];
|
|
||||||
|
|
||||||
pps->ctb_addr_rs_to_ts[ctb_addr_rs] = val;
|
|
||||||
pps->ctb_addr_ts_to_rs[val] = ctb_addr_rs;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0, tile_id = 0; j < pps->num_tile_rows; j++)
|
|
||||||
for (i = 0; i < pps->num_tile_columns; i++, tile_id++)
|
|
||||||
for (y = pps->row_bd[j]; (RK_U32)y < pps->row_bd[j + 1]; y++)
|
|
||||||
for (x = pps->col_bd[i]; (RK_U32)x < pps->col_bd[i + 1]; x++)
|
|
||||||
pps->tile_id[pps->ctb_addr_rs_to_ts[y * sps->ctb_width + x]] = tile_id;
|
|
||||||
|
|
||||||
pps->tile_pos_rs = mpp_malloc(RK_S32, tile_id);
|
|
||||||
if (!pps->tile_pos_rs) {
|
|
||||||
ret = MPP_ERR_NOMEM;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < pps->num_tile_rows; j++)
|
|
||||||
for (i = 0; i < pps->num_tile_columns; i++)
|
|
||||||
pps->tile_pos_rs[j * pps->num_tile_columns + i] = pps->row_bd[j] * sps->ctb_width + pps->col_bd[i];
|
|
||||||
|
|
||||||
if (s->pps_list[pps_id] != NULL) {
|
if (s->pps_list[pps_id] != NULL) {
|
||||||
mpp_hevc_pps_free(s->pps_list[pps_id]);
|
mpp_hevc_pps_free(s->pps_list[pps_id]);
|
||||||
s->pps_list[pps_id] = NULL;
|
s->pps_list[pps_id] = NULL;
|
||||||
|
@@ -171,24 +171,6 @@ int mpp_hevc_set_new_ref(HEVCContext *s, MppFrame *mframe, int poc)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init_slice_rpl(HEVCContext *s)
|
|
||||||
{
|
|
||||||
HEVCFrame *frame = s->ref;
|
|
||||||
RK_S32 ctb_count = frame->ctb_count;
|
|
||||||
RK_S32 ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[s->sh.slice_segment_addr];
|
|
||||||
RK_S32 i;
|
|
||||||
|
|
||||||
if (s->slice_idx >= s->nb_nals)
|
|
||||||
return MPP_ERR_STREAM;
|
|
||||||
|
|
||||||
for (i = ctb_addr_ts; i < ctb_count; i++)
|
|
||||||
frame->rpl_tab[i] = (RefPicListTab *)frame->rpl_buf + s->slice_idx;
|
|
||||||
|
|
||||||
frame->refPicList = (RefPicList *)frame->rpl_tab[ctb_addr_ts];
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HEVCFrame *find_ref_idx(HEVCContext *s, int poc)
|
static HEVCFrame *find_ref_idx(HEVCContext *s, int poc)
|
||||||
{
|
{
|
||||||
RK_U32 i;
|
RK_U32 i;
|
||||||
@@ -215,77 +197,7 @@ static HEVCFrame *find_ref_idx(HEVCContext *s, int poc)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mpp_hevc_slice_rpl(HEVCContext *s)
|
|
||||||
{
|
|
||||||
RK_U8 list_idx;
|
|
||||||
RK_U32 i;
|
|
||||||
RK_S32 j, ret;
|
|
||||||
RefPicList *rpl = NULL;
|
|
||||||
RK_S32 cand_lists[3];
|
|
||||||
|
|
||||||
SliceHeader *sh = &s->sh;
|
|
||||||
RK_U8 nb_list = sh->slice_type == B_SLICE ? 2 : 1;
|
|
||||||
|
|
||||||
ret = init_slice_rpl(s);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (!(s->rps[ST_CURR_BEF].nb_refs + s->rps[ST_CURR_AFT].nb_refs +
|
|
||||||
s->rps[LT_CURR].nb_refs)) {
|
|
||||||
mpp_err( "Zero refs in the frame RPS.\n");
|
|
||||||
return MPP_ERR_STREAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (list_idx = 0; list_idx < nb_list; list_idx++) {
|
|
||||||
RefPicList rpl_tmp;
|
|
||||||
memset(&rpl_tmp, 0, sizeof(rpl_tmp));
|
|
||||||
rpl = &s->ref->refPicList[list_idx];
|
|
||||||
|
|
||||||
/* The order of the elements is
|
|
||||||
* ST_CURR_BEF - ST_CURR_AFT - LT_CURR for the L0 and
|
|
||||||
* ST_CURR_AFT - ST_CURR_BEF - LT_CURR for the L1 */
|
|
||||||
cand_lists[0] = list_idx ? ST_CURR_AFT : ST_CURR_BEF;
|
|
||||||
cand_lists[1] = list_idx ? ST_CURR_BEF : ST_CURR_AFT;
|
|
||||||
cand_lists[2] = LT_CURR;
|
|
||||||
/* concatenate the candidate lists for the current frame */
|
|
||||||
while ((RK_U32)rpl_tmp.nb_refs < sh->nb_refs[list_idx]) {
|
|
||||||
for (i = 0; i < MPP_ARRAY_ELEMS(cand_lists); i++) {
|
|
||||||
RefPicList *rps = &s->rps[cand_lists[i]];
|
|
||||||
for (j = 0; j < rps->nb_refs && rpl_tmp.nb_refs < MAX_REFS; j++) {
|
|
||||||
rpl_tmp.list[rpl_tmp.nb_refs] = rps->list[j];
|
|
||||||
rpl_tmp.ref[rpl_tmp.nb_refs] = rps->ref[j];
|
|
||||||
rpl_tmp.isLongTerm[rpl_tmp.nb_refs] = i == 2;
|
|
||||||
rpl_tmp.nb_refs++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* reorder the references if necessary */
|
|
||||||
if (sh->rpl_modification_flag[list_idx]) {
|
|
||||||
for (i = 0; i < sh->nb_refs[list_idx]; i++) {
|
|
||||||
int idx = sh->list_entry_lx[list_idx][i];
|
|
||||||
|
|
||||||
if (!s->decoder_id && idx >= rpl_tmp.nb_refs) {
|
|
||||||
mpp_err( "Invalid reference index.\n");
|
|
||||||
return MPP_ERR_STREAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
rpl->list[i] = rpl_tmp.list[idx];
|
|
||||||
rpl->ref[i] = rpl_tmp.ref[idx];
|
|
||||||
rpl->isLongTerm[i] = rpl_tmp.isLongTerm[idx];
|
|
||||||
rpl->nb_refs++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
memcpy(rpl, &rpl_tmp, sizeof(*rpl));
|
|
||||||
rpl->nb_refs = MPP_MIN((RK_U32)rpl->nb_refs, sh->nb_refs[list_idx]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sh->collocated_list == list_idx &&
|
|
||||||
sh->collocated_ref_idx < (RK_U32)rpl->nb_refs)
|
|
||||||
s->ref->collocated_ref = rpl->ref[sh->collocated_ref_idx];
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mark_ref(HEVCFrame *frame, int flag)
|
static void mark_ref(HEVCFrame *frame, int flag)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user