Commit d5fcca83 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'b11acd57'

* commit 'b11acd57':
  hevc: remove HEVCContext usage from hevc_ps

Conflicts:
	libavcodec/hevc.c
	libavcodec/hevc_cabac.c
	libavcodec/hevc_filter.c
	libavcodec/hevc_mvs.c
	libavcodec/hevc_ps.c
	libavcodec/hevc_refs.c
	libavcodec/hevcpred_template.c
Merged-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parents 885afff0 b11acd57
This diff is collapsed.
......@@ -557,6 +557,17 @@ typedef struct HEVCPPS {
int *min_tb_addr_zs_tab;///< MinTbAddrZS
} HEVCPPS;
typedef struct HEVCParamSets {
AVBufferRef *vps_list[MAX_VPS_COUNT];
AVBufferRef *sps_list[MAX_SPS_COUNT];
AVBufferRef *pps_list[MAX_PPS_COUNT];
/* currently active parameter sets */
const HEVCVPS *vps;
const HEVCSPS *sps;
const HEVCPPS *pps;
} HEVCParamSets;
typedef struct SliceHeader {
unsigned int pps_id;
......@@ -813,12 +824,7 @@ typedef struct HEVCContext {
uint8_t *sao_pixel_buffer_h[3];
uint8_t *sao_pixel_buffer_v[3];
const HEVCVPS *vps;
const HEVCSPS *sps;
const HEVCPPS *pps;
AVBufferRef *vps_list[MAX_VPS_COUNT];
AVBufferRef *sps_list[MAX_SPS_COUNT];
AVBufferRef *pps_list[MAX_PPS_COUNT];
HEVCParamSets ps;
AVBufferPool *tab_mvf_pool;
AVBufferPool *rpl_tab_pool;
......@@ -939,9 +945,12 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
int apply_defdispwin, AVBufferRef **vps_list, AVCodecContext *avctx);
int ff_hevc_decode_nal_vps(HEVCContext *s);
int ff_hevc_decode_nal_sps(HEVCContext *s);
int ff_hevc_decode_nal_pps(HEVCContext *s);
int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
HEVCParamSets *ps);
int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx,
HEVCParamSets *ps, int apply_defdispwin);
int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
HEVCParamSets *ps);
int ff_hevc_decode_nal_sei(HEVCContext *s);
/**
......
This diff is collapsed.
This diff is collapsed.
......@@ -42,14 +42,14 @@ void ff_hevc_set_neighbour_available(HEVCContext *s, int x0, int y0,
int nPbW, int nPbH)
{
HEVCLocalContext *lc = s->HEVClc;
int x0b = av_mod_uintp2(x0, s->sps->log2_ctb_size);
int y0b = av_mod_uintp2(y0, s->sps->log2_ctb_size);
int x0b = av_mod_uintp2(x0, s->ps.sps->log2_ctb_size);
int y0b = av_mod_uintp2(y0, s->ps.sps->log2_ctb_size);
lc->na.cand_up = (lc->ctb_up_flag || y0b);
lc->na.cand_left = (lc->ctb_left_flag || x0b);
lc->na.cand_up_left = (!x0b && !y0b) ? lc->ctb_up_left_flag : lc->na.cand_left && lc->na.cand_up;
lc->na.cand_up_right_sap =
((x0b + nPbW) == (1 << s->sps->log2_ctb_size)) ?
((x0b + nPbW) == (1 << s->ps.sps->log2_ctb_size)) ?
lc->ctb_up_right_flag && !y0b : lc->na.cand_up;
lc->na.cand_up_right =
lc->na.cand_up_right_sap
......@@ -64,19 +64,19 @@ static av_always_inline int z_scan_block_avail(HEVCContext *s, int xCurr, int yC
int xN, int yN)
{
#define MIN_TB_ADDR_ZS(x, y) \
s->pps->min_tb_addr_zs[(y) * (s->sps->tb_mask+2) + (x)]
s->ps.pps->min_tb_addr_zs[(y) * (s->ps.sps->tb_mask+2) + (x)]
int xCurr_ctb = xCurr >> s->sps->log2_ctb_size;
int yCurr_ctb = yCurr >> s->sps->log2_ctb_size;
int xN_ctb = xN >> s->sps->log2_ctb_size;
int yN_ctb = yN >> s->sps->log2_ctb_size;
int xCurr_ctb = xCurr >> s->ps.sps->log2_ctb_size;
int yCurr_ctb = yCurr >> s->ps.sps->log2_ctb_size;
int xN_ctb = xN >> s->ps.sps->log2_ctb_size;
int yN_ctb = yN >> s->ps.sps->log2_ctb_size;
if( yN_ctb < yCurr_ctb || xN_ctb < xCurr_ctb )
return 1;
else {
int Curr = MIN_TB_ADDR_ZS((xCurr >> s->sps->log2_min_tb_size) & s->sps->tb_mask,
(yCurr >> s->sps->log2_min_tb_size) & s->sps->tb_mask);
int N = MIN_TB_ADDR_ZS((xN >> s->sps->log2_min_tb_size) & s->sps->tb_mask,
(yN >> s->sps->log2_min_tb_size) & s->sps->tb_mask);
int Curr = MIN_TB_ADDR_ZS((xCurr >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask,
(yCurr >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask);
int N = MIN_TB_ADDR_ZS((xN >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask,
(yN >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask);
return N <= Curr;
}
}
......@@ -84,7 +84,7 @@ static av_always_inline int z_scan_block_avail(HEVCContext *s, int xCurr, int yC
//check if the two luma locations belong to the same mostion estimation region
static av_always_inline int is_diff_mer(HEVCContext *s, int xN, int yN, int xP, int yP)
{
uint8_t plevel = s->pps->log2_parallel_merge_level;
uint8_t plevel = s->ps.pps->log2_parallel_merge_level;
return xN >> plevel == xP >> plevel &&
yN >> plevel == yP >> plevel;
......@@ -203,8 +203,8 @@ static int derive_temporal_colocated_mvs(HEVCContext *s, MvField temp_col,
tab_mvf[(y) * min_pu_width + x]
#define TAB_MVF_PU(v) \
TAB_MVF(((x ## v) >> s->sps->log2_min_pu_size), \
((y ## v) >> s->sps->log2_min_pu_size))
TAB_MVF(((x ## v) >> s->ps.sps->log2_min_pu_size), \
((y ## v) >> s->ps.sps->log2_min_pu_size))
#define DERIVE_TEMPORAL_COLOCATED_MVS \
derive_temporal_colocated_mvs(s, temp_col, \
......@@ -221,7 +221,7 @@ static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0,
MvField *tab_mvf;
MvField temp_col;
int x, y, x_pu, y_pu;
int min_pu_width = s->sps->min_pu_width;
int min_pu_width = s->ps.sps->min_pu_width;
int availableFlagLXCol = 0;
int colPic;
......@@ -240,15 +240,15 @@ static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0,
y = y0 + nPbH;
if (tab_mvf &&
(y0 >> s->sps->log2_ctb_size) == (y >> s->sps->log2_ctb_size) &&
y < s->sps->height &&
x < s->sps->width) {
(y0 >> s->ps.sps->log2_ctb_size) == (y >> s->ps.sps->log2_ctb_size) &&
y < s->ps.sps->height &&
x < s->ps.sps->width) {
x &= ~15;
y &= ~15;
if (s->threads_type == FF_THREAD_FRAME)
ff_thread_await_progress(&ref->tf, y, 0);
x_pu = x >> s->sps->log2_min_pu_size;
y_pu = y >> s->sps->log2_min_pu_size;
x_pu = x >> s->ps.sps->log2_min_pu_size;
y_pu = y >> s->ps.sps->log2_min_pu_size;
temp_col = TAB_MVF(x_pu, y_pu);
availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS;
}
......@@ -261,8 +261,8 @@ static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0,
y &= ~15;
if (s->threads_type == FF_THREAD_FRAME)
ff_thread_await_progress(&ref->tf, y, 0);
x_pu = x >> s->sps->log2_min_pu_size;
y_pu = y >> s->sps->log2_min_pu_size;
x_pu = x >> s->ps.sps->log2_min_pu_size;
y_pu = y >> s->ps.sps->log2_min_pu_size;
temp_col = TAB_MVF(x_pu, y_pu);
availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS;
}
......@@ -292,7 +292,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
RefPicList *refPicList = s->ref->refPicList;
MvField *tab_mvf = s->ref->tab_mvf;
const int min_pu_width = s->sps->min_pu_width;
const int min_pu_width = s->ps.sps->min_pu_width;
const int cand_bottom_left = lc->na.cand_bottom_left;
const int cand_left = lc->na.cand_left;
......@@ -365,7 +365,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
// above right spatial merge candidate
is_available_b0 = AVAILABLE(cand_up_right, B0) &&
xB0 < s->sps->width &&
xB0 < s->ps.sps->width &&
PRED_BLOCK_AVAILABLE(B0) &&
!is_diff_mer(s, xB0, yB0, x0, y0);
......@@ -379,7 +379,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
// left bottom spatial merge candidate
is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
yA0 < s->sps->height &&
yA0 < s->ps.sps->height &&
PRED_BLOCK_AVAILABLE(A0) &&
!is_diff_mer(s, xA0, yA0, x0, y0);
......@@ -486,7 +486,7 @@ void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0, int nPbW,
int nPbH2 = nPbH;
HEVCLocalContext *lc = s->HEVClc;
if (s->pps->log2_parallel_merge_level > 2 && nCS == 8) {
if (s->ps.pps->log2_parallel_merge_level > 2 && nCS == 8) {
singleMCLFlag = 1;
x0 = lc->cu.x;
y0 = lc->cu.y;
......@@ -529,7 +529,7 @@ static int mv_mp_mode_mx(HEVCContext *s, int x, int y, int pred_flag_index,
Mv *mv, int ref_idx_curr, int ref_idx)
{
MvField *tab_mvf = s->ref->tab_mvf;
int min_pu_width = s->sps->min_pu_width;
int min_pu_width = s->ps.sps->min_pu_width;
RefPicList *refPicList = s->ref->refPicList;
......@@ -545,7 +545,7 @@ static int mv_mp_mode_mx_lt(HEVCContext *s, int x, int y, int pred_flag_index,
Mv *mv, int ref_idx_curr, int ref_idx)
{
MvField *tab_mvf = s->ref->tab_mvf;
int min_pu_width = s->sps->min_pu_width;
int min_pu_width = s->ps.sps->min_pu_width;
RefPicList *refPicList = s->ref->refPicList;
......@@ -568,14 +568,14 @@ static int mv_mp_mode_mx_lt(HEVCContext *s, int x, int y, int pred_flag_index,
#define MP_MX(v, pred, mx) \
mv_mp_mode_mx(s, \
(x ## v) >> s->sps->log2_min_pu_size, \
(y ## v) >> s->sps->log2_min_pu_size, \
(x ## v) >> s->ps.sps->log2_min_pu_size, \
(y ## v) >> s->ps.sps->log2_min_pu_size, \
pred, &mx, ref_idx_curr, ref_idx)
#define MP_MX_LT(v, pred, mx) \
mv_mp_mode_mx_lt(s, \
(x ## v) >> s->sps->log2_min_pu_size, \
(y ## v) >> s->sps->log2_min_pu_size, \
(x ## v) >> s->ps.sps->log2_min_pu_size, \
(y ## v) >> s->ps.sps->log2_min_pu_size, \
pred, &mx, ref_idx_curr, ref_idx)
void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
......@@ -589,7 +589,7 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
int availableFlagLXA0 = 1;
int availableFlagLXB0 = 1;
int numMVPCandLX = 0;
int min_pu_width = s->sps->min_pu_width;
int min_pu_width = s->ps.sps->min_pu_width;
int xA0, yA0;
int is_available_a0;
......@@ -625,7 +625,7 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
yA0 = y0 + nPbH;
is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
yA0 < s->sps->height &&
yA0 < s->ps.sps->height &&
PRED_BLOCK_AVAILABLE(A0);
//left spatial merge candidate
......@@ -680,7 +680,7 @@ b_candidates:
yB0 = y0 - 1;
is_available_b0 = AVAILABLE(cand_up_right, B0) &&
xB0 < s->sps->width &&
xB0 < s->ps.sps->width &&
PRED_BLOCK_AVAILABLE(B0);
// above spatial merge candidate
......
......@@ -90,6 +90,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx
HEVCContext *h = &((HEVCParseContext *)s->priv_data)->h;
GetBitContext *gb = &h->HEVClc->gb;
SliceHeader *sh = &h->sh;
HEVCParamSets *ps = &h->ps;
const uint8_t *buf_end = buf + buf_size;
int state = -1, i;
HEVCNAL *nal;
......@@ -137,13 +138,13 @@ static inline int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx
init_get_bits8(gb, nal->data + 2, nal->size);
switch (h->nal_unit_type) {
case NAL_VPS:
ff_hevc_decode_nal_vps(h);
ff_hevc_decode_nal_vps(gb, avctx, ps);
break;
case NAL_SPS:
ff_hevc_decode_nal_sps(h);
ff_hevc_decode_nal_sps(gb, avctx, ps, h->apply_defdispwin);
break;
case NAL_PPS:
ff_hevc_decode_nal_pps(h);
ff_hevc_decode_nal_pps(gb, avctx, ps);
break;
case NAL_SEI_PREFIX:
case NAL_SEI_SUFFIX:
......@@ -175,33 +176,33 @@ static inline int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx
}
sh->pps_id = get_ue_golomb(gb);
if (sh->pps_id >= MAX_PPS_COUNT || !h->pps_list[sh->pps_id]) {
if (sh->pps_id >= MAX_PPS_COUNT || !ps->pps_list[sh->pps_id]) {
av_log(h->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
return AVERROR_INVALIDDATA;
}
h->pps = (HEVCPPS*)h->pps_list[sh->pps_id]->data;
ps->pps = (HEVCPPS*)ps->pps_list[sh->pps_id]->data;
if (h->pps->sps_id >= MAX_SPS_COUNT || !h->sps_list[h->pps->sps_id]) {
av_log(h->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", h->pps->sps_id);
if (ps->pps->sps_id >= MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) {
av_log(h->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id);
return AVERROR_INVALIDDATA;
}
if (h->sps != (HEVCSPS*)h->sps_list[h->pps->sps_id]->data) {
h->sps = (HEVCSPS*)h->sps_list[h->pps->sps_id]->data;
h->vps = (HEVCVPS*)h->vps_list[h->sps->vps_id]->data;
if (ps->sps != (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data) {
ps->sps = (HEVCSPS*)ps->sps_list[ps->pps->sps_id]->data;
ps->vps = (HEVCVPS*)ps->vps_list[ps->sps->vps_id]->data;
}
if (!sh->first_slice_in_pic_flag) {
int slice_address_length;
if (h->pps->dependent_slice_segments_enabled_flag)
if (ps->pps->dependent_slice_segments_enabled_flag)
sh->dependent_slice_segment_flag = get_bits1(gb);
else
sh->dependent_slice_segment_flag = 0;
slice_address_length = av_ceil_log2_c(h->sps->ctb_width *
h->sps->ctb_height);
slice_address_length = av_ceil_log2_c(ps->sps->ctb_width *
ps->sps->ctb_height);
sh->slice_segment_addr = slice_address_length ? get_bits(gb, slice_address_length) : 0;
if (sh->slice_segment_addr >= h->sps->ctb_width * h->sps->ctb_height) {
if (sh->slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) {
av_log(h->avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n",
sh->slice_segment_addr);
return AVERROR_INVALIDDATA;
......@@ -212,7 +213,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx
if (sh->dependent_slice_segment_flag)
break;
for (i = 0; i < h->pps->num_extra_slice_header_bits; i++)
for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++)
skip_bits(gb, 1); // slice_reserved_undetermined_flag[]
sh->slice_type = get_ue_golomb(gb);
......@@ -226,14 +227,14 @@ static inline int parse_nal_units(AVCodecParserContext *s, AVCodecContext *avctx
sh->slice_type == P_SLICE ? AV_PICTURE_TYPE_P :
AV_PICTURE_TYPE_I;
if (h->pps->output_flag_present_flag)
if (ps->pps->output_flag_present_flag)
sh->pic_output_flag = get_bits1(gb);
if (h->sps->separate_colour_plane_flag)
if (ps->sps->separate_colour_plane_flag)
sh->colour_plane_id = get_bits(gb, 2);
if (!IS_IDR(h)) {
sh->pic_order_cnt_lsb = get_bits(gb, h->sps->log2_max_poc_lsb);
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);
} else
s->output_picture_number = h->poc = 0;
......@@ -321,19 +322,20 @@ static void hevc_close(AVCodecParserContext *s)
int i;
HEVCContext *h = &((HEVCParseContext *)s->priv_data)->h;
ParseContext *pc = &((HEVCParseContext *)s->priv_data)->pc;
HEVCParamSets *ps = &h->ps;
av_freep(&h->skipped_bytes_pos);
av_freep(&h->HEVClc);
av_freep(&pc->buffer);
for (i = 0; i < FF_ARRAY_ELEMS(h->vps_list); i++)
av_buffer_unref(&h->vps_list[i]);
for (i = 0; i < FF_ARRAY_ELEMS(h->sps_list); i++)
av_buffer_unref(&h->sps_list[i]);
for (i = 0; i < FF_ARRAY_ELEMS(h->pps_list); i++)
av_buffer_unref(&h->pps_list[i]);
for (i = 0; i < FF_ARRAY_ELEMS(ps->vps_list); i++)
av_buffer_unref(&ps->vps_list[i]);
for (i = 0; i < FF_ARRAY_ELEMS(ps->sps_list); i++)
av_buffer_unref(&ps->sps_list[i]);
for (i = 0; i < FF_ARRAY_ELEMS(ps->pps_list); i++)
av_buffer_unref(&ps->pps_list[i]);
h->sps = NULL;
ps->sps = NULL;
for (i = 0; i < h->nals_allocated; i++)
av_freep(&h->nals[i].rbsp_buffer);
......
This diff is collapsed.
......@@ -55,10 +55,10 @@ void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
RefPicList *ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *ref, int x0, int y0)
{
int x_cb = x0 >> s->sps->log2_ctb_size;
int y_cb = y0 >> s->sps->log2_ctb_size;
int pic_width_cb = s->sps->ctb_width;
int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[y_cb * pic_width_cb + x_cb];
int x_cb = x0 >> s->ps.sps->log2_ctb_size;
int y_cb = y0 >> s->ps.sps->log2_ctb_size;
int pic_width_cb = s->ps.sps->ctb_width;
int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[y_cb * pic_width_cb + x_cb];
return (RefPicList *)ref->rpl_tab[ctb_addr_ts];
}
......@@ -104,7 +104,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
if (!frame->rpl_tab_buf)
goto fail;
frame->rpl_tab = (RefPicListTab **)frame->rpl_tab_buf->data;
frame->ctb_count = s->sps->ctb_width * s->sps->ctb_height;
frame->ctb_count = s->ps.sps->ctb_width * s->ps.sps->ctb_height;
for (j = 0; j < frame->ctb_count; j++)
frame->rpl_tab[j] = (RefPicListTab *)frame->rpl_buf->data;
......@@ -162,7 +162,7 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
ref->poc = poc;
ref->sequence = s->seq_decode;
ref->window = s->sps->output_window;
ref->window = s->ps.sps->output_window;
return 0;
}
......@@ -197,8 +197,8 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush)
}
/* wait for more frames before output */
if (!flush && s->seq_output == s->seq_decode && s->sps &&
nb_output <= s->sps->temporal_layer[s->sps->max_sub_layers - 1].num_reorder_pics)
if (!flush && s->seq_output == s->seq_decode && s->ps.sps &&
nb_output <= s->ps.sps->temporal_layer[s->ps.sps->max_sub_layers - 1].num_reorder_pics)
return 0;
if (nb_output) {
......@@ -252,7 +252,7 @@ void ff_hevc_bump_frame(HEVCContext *s)
}
}
if (s->sps && dpb >= s->sps->temporal_layer[s->sps->max_sub_layers - 1].max_dec_pic_buffering) {
if (s->ps.sps && dpb >= s->ps.sps->temporal_layer[s->ps.sps->max_sub_layers - 1].max_dec_pic_buffering) {
for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
HEVCFrame *frame = &s->DPB[i];
if ((frame->flags) &&
......@@ -281,7 +281,7 @@ static int init_slice_rpl(HEVCContext *s)
{
HEVCFrame *frame = s->ref;
int ctb_count = frame->ctb_count;
int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[s->sh.slice_segment_addr];
int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_segment_addr];
int i;
if (s->slice_idx >= frame->rpl_buf->size / sizeof(RefPicListTab))
......@@ -368,7 +368,7 @@ int ff_hevc_slice_rpl(HEVCContext *s)
static HEVCFrame *find_ref_idx(HEVCContext *s, int poc)
{
int i;
int LtMask = (1 << s->sps->log2_max_poc_lsb) - 1;
int LtMask = (1 << s->ps.sps->log2_max_poc_lsb) - 1;
for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
HEVCFrame *ref = &s->DPB[i];
......@@ -408,16 +408,16 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
return NULL;
if (!s->avctx->hwaccel) {
if (!s->sps->pixel_shift) {
if (!s->ps.sps->pixel_shift) {
for (i = 0; frame->frame->buf[i]; i++)
memset(frame->frame->buf[i]->data, 1 << (s->sps->bit_depth - 1),
memset(frame->frame->buf[i]->data, 1 << (s->ps.sps->bit_depth - 1),
frame->frame->buf[i]->size);
} else {
for (i = 0; frame->frame->data[i]; i++)
for (y = 0; y < (s->sps->height >> s->sps->vshift[i]); y++)
for (x = 0; x < (s->sps->width >> s->sps->hshift[i]); x++) {
for (y = 0; y < (s->ps.sps->height >> s->ps.sps->vshift[i]); y++)
for (x = 0; x < (s->ps.sps->width >> s->ps.sps->hshift[i]); x++) {
AV_WN16(frame->frame->data[i] + y * frame->frame->linesize[i] + 2 * x,
1 << (s->sps->bit_depth - 1));
1 << (s->ps.sps->bit_depth - 1));
}
}
}
......@@ -517,7 +517,7 @@ fail:
int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb)
{
int max_poc_lsb = 1 << s->sps->log2_max_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;
......
......@@ -94,9 +94,9 @@ static int decode_pic_timing(HEVCContext *s)
GetBitContext *gb = &s->HEVClc->gb;
HEVCSPS *sps;
if (!s->sps_list[s->active_seq_parameter_set_id])
if (!s->ps.sps_list[s->active_seq_parameter_set_id])
return(AVERROR(ENOMEM));
sps = (HEVCSPS*)s->sps_list[s->active_seq_parameter_set_id]->data;
sps = (HEVCSPS*)s->ps.sps_list[s->active_seq_parameter_set_id]->data;
if (sps->vui.frame_field_info_present_flag) {
int pic_struct = get_bits(gb, 4);
......
......@@ -31,7 +31,7 @@ static av_always_inline void FUNC(intra_pred)(HEVCContext *s, int x0, int y0,
int log2_size, int c_idx)
{
#define PU(x) \
((x) >> s->sps->log2_min_pu_size)
((x) >> s->ps.sps->log2_min_pu_size)
#define MVF(x, y) \
(s->ref->tab_mvf[(x) + (y) * min_pu_width])
#define MVF_PU(x, y) \
......@@ -39,7 +39,7 @@ static av_always_inline void FUNC(intra_pred)(HEVCContext *s, int x0, int y0,
#define IS_INTRA(x, y) \
(MVF_PU(x, y).pred_flag == PF_INTRA)
#define MIN_TB_ADDR_ZS(x, y) \
s->pps->min_tb_addr_zs[(y) * (s->sps->tb_mask+2) + (x)]
s->ps.pps->min_tb_addr_zs[(y) * (s->ps.sps->tb_mask+2) + (x)]
#define EXTEND(ptr, val, len) \
do { \
pixel4 pix = PIXEL_SPLAT_X4(val); \
......@@ -72,24 +72,24 @@ do { \
HEVCLocalContext *lc = s->HEVClc;
int i;
int hshift = s->sps->hshift[c_idx];
int vshift = s->sps->vshift[c_idx];
int hshift = s->ps.sps->hshift[c_idx];
int vshift = s->ps.sps->vshift[c_idx];
int size = (1 << log2_size);
int size_in_luma_h = size << hshift;
int size_in_tbs_h = size_in_luma_h >> s->sps->log2_min_tb_size;
int size_in_tbs_h = size_in_luma_h >> s->ps.sps->log2_min_tb_size;
int size_in_luma_v = size << vshift;
int size_in_tbs_v = size_in_luma_v >> s->sps->log2_min_tb_size;
int size_in_tbs_v = size_in_luma_v >> s->ps.sps->log2_min_tb_size;
int x = x0 >> hshift;
int y = y0 >> vshift;
int x_tb = (x0 >> s->sps->log2_min_tb_size) & s->sps->tb_mask;
int y_tb = (y0 >> s->sps->log2_min_tb_size) & s->sps->tb_mask;
int x_tb = (x0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
int y_tb = (y0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb);
ptrdiff_t stride = s->frame->linesize[c_idx] / sizeof(pixel);
pixel *src = (pixel*)s->frame->data[c_idx] + x + y * stride;
int min_pu_width = s->sps->min_pu_width;
int min_pu_width = s->ps.sps->min_pu_width;
enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c :
lc->tu.intra_pred_mode;
......@@ -103,28 +103,28 @@ do { \
pixel *top = top_array + 1;
pixel *filtered_left = filtered_left_array + 1;
pixel *filtered_top = filtered_top_array + 1;
int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS( x_tb - 1, (y_tb + size_in_tbs_v) & s->sps->tb_mask);
int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS( x_tb - 1, (y_tb + size_in_tbs_v) & s->ps.sps->tb_mask);
int cand_left = lc->na.cand_left;
int cand_up_left = lc->na.cand_up_left;
int cand_up = lc->na.cand_up;
int cand_up_right = lc->na.cand_up_right && cur_tb_addr > MIN_TB_ADDR_ZS((x_tb + size_in_tbs_h) & s->sps->tb_mask, y_tb - 1);
int cand_up_right = lc->na.cand_up_right && cur_tb_addr > MIN_TB_ADDR_ZS((x_tb + size_in_tbs_h) & s->ps.sps->tb_mask, y_tb - 1);
int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, s->sps->height) -
int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, s->ps.sps->height) -
(y0 + size_in_luma_v)) >> vshift;
int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, s->sps->width) -
int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, s->ps.sps->width) -
(x0 + size_in_luma_h)) >> hshift;
if (s->pps->constrained_intra_pred_flag == 1) {
if (s->ps.pps->constrained_intra_pred_flag == 1) {
int size_in_luma_pu_v = PU(size_in_luma_v);
int size_in_luma_pu_h = PU(size_in_luma_h);
int on_pu_edge_x = !av_mod_uintp2(x0, s->sps->log2_min_pu_size);
int on_pu_edge_y = !av_mod_uintp2(y0, s->sps->log2_min_pu_size);
int on_pu_edge_x = !av_mod_uintp2(x0, s->ps.sps->log2_min_pu_size);
int on_pu_edge_y = !av_mod_uintp2(y0, s->ps.sps->log2_min_pu_size);
if (!size_in_luma_pu_h)
size_in_luma_pu_h++;
if (cand_bottom_left == 1 && on_pu_edge_x) {
int x_left_pu = PU(x0 - 1);
int y_bottom_pu = PU(y0 + size_in_luma_v);
int max = FFMIN(size_in_luma_pu_v, s->sps->min_pu_height - y_bottom_pu);
int max = FFMIN(size_in_luma_pu_v, s->ps.sps->min_pu_height - y_bottom_pu);
cand_bottom_left = 0;
for (i = 0; i < max; i += 2)
cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA);
......@@ -132,7 +132,7 @@ do { \
if (cand_left == 1 && on_pu_edge_x) {
int x_left_pu = PU(x0 - 1);
int y_left_pu = PU(y0);
int max = FFMIN(size_in_luma_pu_v, s->sps->min_pu_height - y_left_pu);
int max = FFMIN(size_in_luma_pu_v, s->ps.sps->min_pu_height - y_left_pu);
cand_left = 0;
for (i = 0; i < max; i += 2)
cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA);
......@@ -145,7 +145,7 @@ do { \
if (cand_up == 1 && on_pu_edge_y) {
int x_top_pu = PU(x0);
int y_top_pu = PU(y0 - 1);
int max = FFMIN(size_in_luma_pu_h, s->sps->min_pu_width - x_top_pu);
int max = FFMIN(size_in_luma_pu_h, s->ps.sps->min_pu_width - x_top_pu);
cand_up = 0;
for (i = 0; i < max; i += 2)
cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA);
......@@ -153,7 +153,7 @@ do { \
if (cand_up_right == 1 && on_pu_edge_y) {
int y_top_pu = PU(y0 - 1);
int x_right_pu = PU(x0 + size_in_luma_h);
int max = FFMIN(size_in_luma_pu_h, s->sps->min_pu_width - x_right_pu);
int max = FFMIN(size_in_luma_pu_h, s->ps.sps->min_pu_width - x_right_pu);
cand_up_right = 0;
for (i = 0; i < max; i += 2)
cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA);
......@@ -183,20 +183,20 @@ do { \
size - bottom_left_size);
}
if (s->pps->constrained_intra_pred_flag == 1) {
if (s->ps.pps->constrained_intra_pred_flag == 1) {
if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) {
int size_max_x = x0 + ((2 * size) << hshift) < s->sps->width ?
2 * size : (s->sps->width - x0) >> hshift;
int size_max_y = y0 + ((2 * size) << vshift) < s->sps->height ?
2 * size : (s->sps->height - y0) >> vshift;
int size_max_x = x0 + ((2 * size) << hshift) < s->ps.sps->width ?
2 * size : (s->ps.sps->width - x0) >> hshift;
int size_max_y = y0 + ((2 * size) << vshift) < s->ps.sps->height ?
2 * size : (s->ps.sps->height - y0) >> vshift;
int j = size + (cand_bottom_left? bottom_left_size: 0) -1;
if (!cand_up_right) {
size_max_x = x0 + ((size) << hshift) < s->sps->width ?
size : (s->sps->width - x0) >> hshift;
size_max_x = x0 + ((size) << hshift) < s->ps.sps->width ?
size : (s->ps.sps->width - x0) >> hshift;
}
if (!cand_bottom_left) {
size_max_y = y0 + (( size) << vshift) < s->sps->height ?
size : (s->sps->height - y0) >> vshift;
size_max_y = y0 + (( size) << vshift) < s->ps.sps->height ?
size : (s->ps.sps->height - y0) >> vshift;
}
if (cand_bottom_left || cand_left || cand_up_left) {
while (j > -1 && !IS_INTRA(-1, j))
......@@ -287,14 +287,14 @@ do { \
top[-1] = left[-1];
// Filtering process
if (!s->sps->intra_smoothing_disabled_flag && (c_idx == 0 || s->sps->chroma_format_idc == 3)) {
if (!s->ps.sps->intra_smoothing_disabled_flag && (c_idx == 0 || s->ps.sps->chroma_format_idc == 3)) {
if (mode != INTRA_DC && size != 4){
int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };
int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)),
FFABS((int)(mode - 10U)));
if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) {
int threshold = 1 << (BIT_DEPTH - 5);
if (s->sps->sps_strong_intra_smoothing_enable_flag && c_idx == 0 &&
if (s->ps.sps->sps_strong_intra_smoothing_enable_flag && c_idx == 0 &&
log2_size == 5 &&
FFABS(top[-1] + top[63] - 2 * top[31]) < threshold &&
FFABS(left[-1] + left[63] - 2 * left[31]) < threshold) {
......
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