Lines Matching refs:s
37 void mpp_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags) in mpp_hevc_unref_frame() argument
49 mpp_buf_slot_clr_flag(s->slots, frame->slot_index, SLOT_CODEC_USE); in mpp_hevc_unref_frame()
59 void mpp_hevc_clear_refs(HEVCContext *s) in mpp_hevc_clear_refs() argument
62 for (i = 0; i < MPP_ARRAY_ELEMS(s->DPB); i++) { in mpp_hevc_clear_refs()
63 mpp_hevc_unref_frame(s, &s->DPB[i], in mpp_hevc_clear_refs()
69 void mpp_hevc_flush_dpb(HEVCContext *s) in mpp_hevc_flush_dpb() argument
72 for (i = 0; i < MPP_ARRAY_ELEMS(s->DPB); i++) { in mpp_hevc_flush_dpb()
73 mpp_hevc_unref_frame(s, &s->DPB[i], ~0); in mpp_hevc_flush_dpb()
82 static HEVCFrame *alloc_frame(HEVCContext *s) in alloc_frame() argument
86 MppFrameFormat fmt = s->h265dctx->cfg->base.out_fmt & (~MPP_FRAME_FMT_MASK); in alloc_frame()
88 for (i = 0; i < MPP_ARRAY_ELEMS(s->DPB); i++) { in alloc_frame()
89 HEVCFrame *frame = &s->DPB[i]; in alloc_frame()
94 … h265d_dbg(H265D_DBG_GLOBAL, "width = %d height = %d", s->h265dctx->width, s->h265dctx->height); in alloc_frame()
95 mpp_frame_set_width(frame->frame, s->h265dctx->width); in alloc_frame()
96 mpp_frame_set_height(frame->frame, s->h265dctx->height); in alloc_frame()
98 … (MPP_ALIGN(s->h265dctx->coded_width, 64) * s->h265dctx->nBitDepth) >> 3); in alloc_frame()
99 mpp_frame_set_ver_stride(frame->frame, s->h265dctx->coded_height); in alloc_frame()
100 s->h265dctx->pix_fmt &= MPP_FRAME_FMT_MASK; in alloc_frame()
101 if (s->is_hdr) { in alloc_frame()
102 s->h265dctx->pix_fmt |= MPP_FRAME_HDR; in alloc_frame()
104 s->h265dctx->pix_fmt |= fmt; in alloc_frame()
105 mpp_frame_set_fmt(frame->frame, s->h265dctx->pix_fmt); in alloc_frame()
107 if (MPP_FRAME_FMT_IS_FBC(s->h265dctx->pix_fmt)) { in alloc_frame()
108 RK_U32 fbc_hdr_stride = MPP_ALIGN(s->h265dctx->width, 64); in alloc_frame()
110 mpp_slots_set_prop(s->slots, SLOTS_HOR_ALIGN, hor_align_64); in alloc_frame()
115 mpp_frame_set_ver_stride(frame->frame, s->h265dctx->coded_height + 16); in alloc_frame()
118 fbc_hdr_stride = MPP_ALIGN(s->h265dctx->width, 256) | 256; in alloc_frame()
121 } else if (MPP_FRAME_FMT_IS_TILE(s->h265dctx->pix_fmt)) { in alloc_frame()
124 if ((s->h265dctx->cfg->base.enable_vproc & MPP_VPROC_MODE_DETECTION) && in alloc_frame()
125 s->h265dctx->width <= 1920 && s->h265dctx->height <= 1088) in alloc_frame()
129 if (s->h265dctx->cfg->base.enable_thumbnail && s->h265dctx->hw_info->cap_down_scale) in alloc_frame()
130 mpp_frame_set_thumbnail_en(frame->frame, s->h265dctx->cfg->base.enable_thumbnail); in alloc_frame()
136 mpp_frame_set_pts(frame->frame, s->pts); in alloc_frame()
137 mpp_frame_set_dts(frame->frame, s->dts); in alloc_frame()
138 mpp_frame_set_poc(frame->frame, s->poc); in alloc_frame()
139 mpp_frame_set_color_range(frame->frame, s->h265dctx->color_range); in alloc_frame()
140 mpp_frame_set_color_primaries(frame->frame, s->sps->vui.colour_primaries); in alloc_frame()
141 if (s->alternative_transfer.present) in alloc_frame()
143 s->alternative_transfer.preferred_transfer_characteristics); in alloc_frame()
145 mpp_frame_set_color_trc(frame->frame, s->sps->vui.transfer_characteristic); in alloc_frame()
146 mpp_frame_set_colorspace(frame->frame, s->h265dctx->colorspace); in alloc_frame()
147 mpp_frame_set_mastering_display(frame->frame, s->mastering_display); in alloc_frame()
148 mpp_frame_set_content_light(frame->frame, s->content_light); in alloc_frame()
151 s->poc, s->h265dctx->coded_width, s->h265dctx->coded_height); in alloc_frame()
152 ret = mpp_buf_slot_get_unused(s->slots, &frame->slot_index); in alloc_frame()
160 int mpp_hevc_set_new_ref(HEVCContext *s, MppFrame *mframe, int poc) in mpp_hevc_set_new_ref() argument
167 for (i = 0; i < MPP_ARRAY_ELEMS(s->DPB); i++) { in mpp_hevc_set_new_ref()
168 HEVCFrame *frame = &s->DPB[i]; in mpp_hevc_set_new_ref()
170 if ((frame->slot_index != 0xff) && frame->sequence == s->seq_decode && in mpp_hevc_set_new_ref()
171 frame->poc == poc && !s->nuh_layer_id) { in mpp_hevc_set_new_ref()
178 ref = alloc_frame(s); in mpp_hevc_set_new_ref()
184 if (s->hdr_dynamic_meta && s->hdr_dynamic) { in mpp_hevc_set_new_ref()
185 mpp_frame_set_hdr_dynamic_meta(ref->frame, s->hdr_dynamic_meta); in mpp_hevc_set_new_ref()
186 s->hdr_dynamic = 0; in mpp_hevc_set_new_ref()
190 s->ref = ref; in mpp_hevc_set_new_ref()
194 mpp_buf_slot_set_flag(s->slots, ref->slot_index, SLOT_CODEC_USE); in mpp_hevc_set_new_ref()
195 mpp_buf_slot_set_flag(s->slots, ref->slot_index, SLOT_HAL_OUTPUT); in mpp_hevc_set_new_ref()
196 s->task->output = ref->slot_index; in mpp_hevc_set_new_ref()
198 ref->sequence = s->seq_decode; in mpp_hevc_set_new_ref()
199 ref->window = s->sps->output_window; in mpp_hevc_set_new_ref()
203 static HEVCFrame *find_ref_idx(HEVCContext *s, int poc) in find_ref_idx() argument
206 RK_S32 LtMask = (1 << s->sps->log2_max_poc_lsb) - 1; in find_ref_idx()
208 for (i = 0; i < MPP_ARRAY_ELEMS(s->DPB); i++) { in find_ref_idx()
209 HEVCFrame *ref = &s->DPB[i]; in find_ref_idx()
210 if ((ref->slot_index != 0xff) && (ref->sequence == s->seq_decode)) { in find_ref_idx()
216 for (i = 0; i < MPP_ARRAY_ELEMS(s->DPB); i++) { in find_ref_idx()
217 HEVCFrame *ref = &s->DPB[i]; in find_ref_idx()
218 if ((ref->slot_index != 0xff) && ref->sequence == s->seq_decode) { in find_ref_idx()
223 mpp_err("cur_poc %d Could not find ref with POC %d\n", s->poc, poc); in find_ref_idx()
233 static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc) in generate_missing_ref() argument
237 frame = alloc_frame(s); in generate_missing_ref()
243 mpp_buf_slot_set_prop(s->slots, frame->slot_index, SLOT_FRAME, frame->frame); in generate_missing_ref()
244 mpp_buf_slot_set_flag(s->slots, frame->slot_index, SLOT_CODEC_READY); in generate_missing_ref()
245 mpp_buf_slot_set_flag(s->slots, frame->slot_index, SLOT_CODEC_USE); in generate_missing_ref()
248 frame->sequence = s->seq_decode; in generate_missing_ref()
254 static int add_candidate_ref(HEVCContext *s, RefPicList *list, in add_candidate_ref() argument
257 HEVCFrame *ref = find_ref_idx(s, poc); in add_candidate_ref()
260 ref = generate_missing_ref(s, poc); in add_candidate_ref()
272 mpp_buf_slot_set_flag(s->slots, ref->slot_index, SLOT_CODEC_USE); in add_candidate_ref()
276 s->miss_ref_flag = 1; in add_candidate_ref()
281 RK_S32 mpp_hevc_frame_rps(HEVCContext *s) in mpp_hevc_frame_rps() argument
284 const ShortTermRPS *short_rps = s->sh.short_term_rps; in mpp_hevc_frame_rps()
285 const LongTermRPS *long_rps = &s->sh.long_term_rps; in mpp_hevc_frame_rps()
286 RefPicList *rps = s->rps; in mpp_hevc_frame_rps()
296 for (i = 0; i < MPP_ARRAY_ELEMS(s->DPB); i++) { in mpp_hevc_frame_rps()
297 HEVCFrame *frame = &s->DPB[i]; in mpp_hevc_frame_rps()
306 int poc = s->poc + short_rps->delta_poc[i]; in mpp_hevc_frame_rps()
316 ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_SHORT_REF, ST_FOLL != list); in mpp_hevc_frame_rps()
326 ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_LONG_REF, LT_FOLL != list); in mpp_hevc_frame_rps()
331 for (i = 0; i < MPP_ARRAY_ELEMS(s->DPB); i++) { in mpp_hevc_frame_rps()
332 mpp_hevc_unref_frame(s, &s->DPB[i], 0); in mpp_hevc_frame_rps()
337 if (IS_CRA(s)) { in mpp_hevc_frame_rps()
338 for (i = 0; i < MPP_ARRAY_ELEMS(s->DPB); i++) { in mpp_hevc_frame_rps()
339 HEVCFrame *ref = &s->DPB[i]; in mpp_hevc_frame_rps()
341 if ((ref->slot_index != 0xff) && (ref->poc > s->poc)) { in mpp_hevc_frame_rps()
342 h265d_flush(s->h265dctx); in mpp_hevc_frame_rps()
351 int mpp_hevc_compute_poc(HEVCContext *s, int poc_lsb) in mpp_hevc_compute_poc() argument
353 RK_S32 max_poc_lsb = 1 << s->sps->log2_max_poc_lsb; in mpp_hevc_compute_poc()
354 RK_S32 prev_poc_lsb = s->pocTid0 % max_poc_lsb; in mpp_hevc_compute_poc()
355 RK_S32 prev_poc_msb = s->pocTid0 - prev_poc_lsb; in mpp_hevc_compute_poc()
366 if (s->nal_unit_type == NAL_BLA_W_LP || in mpp_hevc_compute_poc()
367 s->nal_unit_type == NAL_BLA_W_RADL || in mpp_hevc_compute_poc()
368 s->nal_unit_type == NAL_BLA_N_LP) in mpp_hevc_compute_poc()
374 int mpp_hevc_frame_nb_refs(HEVCContext *s) in mpp_hevc_frame_nb_refs() argument
378 const ShortTermRPS *rps = s->sh.short_term_rps; in mpp_hevc_frame_nb_refs()
379 LongTermRPS *long_rps = &s->sh.long_term_rps; in mpp_hevc_frame_nb_refs()
381 if (s->sh.slice_type == I_SLICE) { in mpp_hevc_frame_nb_refs()