mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec/hevcdec: remove HEVCContext usage from ff_hevc_compute_poc()
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>
This commit is contained in:
parent
a687fb9970
commit
1d53b8e907
@ -379,7 +379,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
|
||||
|
||||
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;
|
||||
|
||||
|
@ -1665,3 +1665,26 @@ err:
|
||||
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;
|
||||
}
|
||||
|
@ -344,4 +344,9 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
|
||||
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 */
|
||||
|
@ -516,29 +516,6 @@ fail:
|
||||
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;
|
||||
|
@ -541,7 +541,7 @@ static int hls_slice_header(HEVCContext *s)
|
||||
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);
|
||||
|
@ -579,11 +579,6 @@ void ff_hevc_clear_refs(HEVCContext *s);
|
||||
*/
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user