Move it to hevc_ps as well. This is in preparation for a following patch.
Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Reviewed-by: Aaron Levinson <alevinsn@aracnet.com>
Signed-off-by: James Almer <jamrial@gmail.com>
if (!IS_IDR(h)) {
sh->pic_order_cnt_lsb = get_bits(gb, ps->sps->log2_max_poc_lsb);
- s->output_picture_number = h->poc = ff_hevc_compute_poc(h, sh->pic_order_cnt_lsb);
+ s->output_picture_number = h->poc = ff_hevc_compute_poc(h->ps.sps, h->pocTid0, sh->pic_order_cnt_lsb, h->nal_unit_type);
} else
s->output_picture_number = h->poc = 0;
av_buffer_unref(&pps_buf);
return ret;
}
+
+int ff_hevc_compute_poc(const HEVCSPS *sps, int pocTid0, int poc_lsb, int nal_unit_type)
+{
+ int max_poc_lsb = 1 << sps->log2_max_poc_lsb;
+ int prev_poc_lsb = pocTid0 % max_poc_lsb;
+ int prev_poc_msb = pocTid0 - prev_poc_lsb;
+ int poc_msb;
+
+ if (poc_lsb < prev_poc_lsb && prev_poc_lsb - poc_lsb >= max_poc_lsb / 2)
+ poc_msb = prev_poc_msb + max_poc_lsb;
+ else if (poc_lsb > prev_poc_lsb && poc_lsb - prev_poc_lsb > max_poc_lsb / 2)
+ poc_msb = prev_poc_msb - max_poc_lsb;
+ else
+ poc_msb = prev_poc_msb;
+
+ // For BLA picture types, POCmsb is set to 0.
+ if (nal_unit_type == HEVC_NAL_BLA_W_LP ||
+ nal_unit_type == HEVC_NAL_BLA_W_RADL ||
+ nal_unit_type == HEVC_NAL_BLA_N_LP)
+ poc_msb = 0;
+
+ return poc_msb + poc_lsb;
+}
int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id,
uint8_t *buf, int buf_size);
+/**
+ * Compute POC of the current frame and return it.
+ */
+int ff_hevc_compute_poc(const HEVCSPS *sps, int pocTid0, int poc_lsb, int nal_unit_type);
+
#endif /* AVCODEC_HEVC_PS_H */
return ret;
}
-int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb)
-{
- int max_poc_lsb = 1 << s->ps.sps->log2_max_poc_lsb;
- int prev_poc_lsb = s->pocTid0 % max_poc_lsb;
- int prev_poc_msb = s->pocTid0 - prev_poc_lsb;
- int poc_msb;
-
- if (poc_lsb < prev_poc_lsb && prev_poc_lsb - poc_lsb >= max_poc_lsb / 2)
- poc_msb = prev_poc_msb + max_poc_lsb;
- else if (poc_lsb > prev_poc_lsb && poc_lsb - prev_poc_lsb > max_poc_lsb / 2)
- poc_msb = prev_poc_msb - max_poc_lsb;
- else
- poc_msb = prev_poc_msb;
-
- // For BLA picture types, POCmsb is set to 0.
- if (s->nal_unit_type == HEVC_NAL_BLA_W_LP ||
- s->nal_unit_type == HEVC_NAL_BLA_W_RADL ||
- s->nal_unit_type == HEVC_NAL_BLA_N_LP)
- poc_msb = 0;
-
- return poc_msb + poc_lsb;
-}
-
int ff_hevc_frame_nb_refs(HEVCContext *s)
{
int ret = 0;
int poc, pos;
sh->pic_order_cnt_lsb = get_bits(gb, s->ps.sps->log2_max_poc_lsb);
- poc = ff_hevc_compute_poc(s, sh->pic_order_cnt_lsb);
+ poc = ff_hevc_compute_poc(s->ps.sps, s->pocTid0, sh->pic_order_cnt_lsb, s->nal_unit_type);
if (!sh->first_slice_in_pic_flag && poc != s->poc) {
av_log(s->avctx, AV_LOG_WARNING,
"Ignoring POC change between slices: %d -> %d\n", s->poc, poc);
*/
void ff_hevc_flush_dpb(HEVCContext *s);
-/**
- * Compute POC of the current frame and return it.
- */
-int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb);
-
RefPicList *ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *frame,
int x0, int y0);