1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

hevc: more cosmetic(cherry picked from commit 9697abe41daa234602915f85bf6b1c0ca0252cff)

Decreases the difference to Anton Khirnovs patch v5

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Mickaël Raulet 2013-10-27 13:29:50 +01:00 committed by Michael Niedermayer
parent 3c3ece24ea
commit 3106cbd321
2 changed files with 131 additions and 136 deletions

View File

@ -89,9 +89,9 @@ static int pic_arrays_init(HEVCContext *s)
int pic_size_in_ctb = ((width >> log2_min_cb_size) + 1) *
((height >> log2_min_cb_size) + 1);
int ctb_count = s->sps->ctb_width * s->sps->ctb_height;
int pic_width_in_min_pu = width >> s->sps->log2_min_pu_size;
int min_pu_width = width >> s->sps->log2_min_pu_size;
int pic_height_in_min_pu = height >> s->sps->log2_min_pu_size;
int pic_size_in_min_pu = pic_width_in_min_pu * pic_height_in_min_pu;
int pic_size_in_min_pu = min_pu_width * pic_height_in_min_pu;
int pic_width_in_min_tu = width >> s->sps->log2_min_tb_size;
int pic_height_in_min_tu = height >> s->sps->log2_min_tb_size;
@ -128,12 +128,9 @@ static int pic_arrays_init(HEVCContext *s)
s->tab_mvf_pool = av_buffer_pool_init(pic_size_in_min_pu * sizeof(MvField),
av_buffer_alloc);
if (!s->tab_mvf_pool)
goto fail;
s->rpl_tab_pool = av_buffer_pool_init(ctb_count * sizeof(RefPicListTab),
av_buffer_allocz);
if (!s->rpl_tab_pool)
if (!s->tab_mvf_pool || !s->rpl_tab_pool)
goto fail;
return 0;
@ -164,15 +161,13 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
s->sh.luma_offset_l0[i] = 0;
}
}
if (s->sps->chroma_format_idc != 0) { //fix me ! invert "if" and "for"
for (i = 0; i < s->sh.nb_refs[L0]; i++) {
if (s->sps->chroma_format_idc != 0) { // FIXME: invert "if" and "for"
for (i = 0; i < s->sh.nb_refs[L0]; i++)
chroma_weight_l0_flag[i] = get_bits1(gb);
}
} else {
for (i = 0; i < s->sh.nb_refs[L0]; i++) {
for (i = 0; i < s->sh.nb_refs[L0]; i++)
chroma_weight_l0_flag[i] = 0;
}
}
for (i = 0; i < s->sh.nb_refs[L0]; i++) {
if (luma_weight_l0_flag[i]) {
int delta_luma_weight_l0 = get_se_golomb(gb);
@ -203,14 +198,12 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
}
}
if (s->sps->chroma_format_idc != 0) {
for (i = 0; i < s->sh.nb_refs[L1]; i++) {
for (i = 0; i < s->sh.nb_refs[L1]; i++)
chroma_weight_l1_flag[i] = get_bits1(gb);
}
} else {
for (i = 0; i < s->sh.nb_refs[L1]; i++) {
for (i = 0; i < s->sh.nb_refs[L1]; i++)
chroma_weight_l1_flag[i] = 0;
}
}
for (i = 0; i < s->sh.nb_refs[L1]; i++) {
if (luma_weight_l1_flag[i]) {
int delta_luma_weight_l1 = get_se_golomb(gb);
@ -450,6 +443,7 @@ static int hls_slice_header(HEVCContext *s)
s->poc = 0;
}
/* 8.3.1 */
if (s->temporal_id == 0 &&
s->nal_unit_type != NAL_TRAIL_N &&
s->nal_unit_type != NAL_TSA_N &&
@ -462,8 +456,8 @@ static int hls_slice_header(HEVCContext *s)
if (s->sps->sao_enabled) {
sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);
sh->slice_sample_adaptive_offset_flag[2] =
sh->slice_sample_adaptive_offset_flag[1] = get_bits1(gb);
sh->slice_sample_adaptive_offset_flag[1] =
sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb);
} else {
sh->slice_sample_adaptive_offset_flag[0] = 0;
sh->slice_sample_adaptive_offset_flag[1] = 0;
@ -542,6 +536,12 @@ static int hls_slice_header(HEVCContext *s)
}
sh->max_num_merge_cand = 5 - get_ue_golomb_long(gb);
if (sh->max_num_merge_cand < 1 || sh->max_num_merge_cand > 5) {
av_log(s->avctx, AV_LOG_ERROR,
"Invalid number of merging MVP candidates: %d.\n",
sh->max_num_merge_cand);
return AVERROR_INVALIDDATA;
}
}
sh->slice_qp_delta = get_se_golomb(gb);
@ -729,12 +729,12 @@ static void hls_sao_param(HEVCContext *s, int rx, int ry)
#undef CTB
static void hls_transform_unit(HEVCContext *s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase,
int log2_cb_size, int log2_trafo_size, int trafo_depth, int blk_idx)
static void hls_transform_unit(HEVCContext *s, int x0, int y0,
int xBase, int yBase, int cb_xBase, int cb_yBase,
int log2_cb_size, int log2_trafo_size,
int trafo_depth, int blk_idx)
{
HEVCLocalContext *lc = s->HEVClc;
int scan_idx = SCAN_DIAG;
int scan_idx_c = SCAN_DIAG;
if (lc->cu.pred_mode == MODE_INTRA) {
int trafo_size = 1 << log2_trafo_size;
@ -757,6 +757,9 @@ static void hls_transform_unit(HEVCContext *s, int x0, int y0, int xBase, int y
if (lc->tt.cbf_luma ||
SAMPLE_CBF(lc->tt.cbf_cb[trafo_depth], x0, y0) ||
SAMPLE_CBF(lc->tt.cbf_cr[trafo_depth], x0, y0)) {
int scan_idx = SCAN_DIAG;
int scan_idx_c = SCAN_DIAG;
if (s->pps->cu_qp_delta_enabled_flag && !lc->tu.is_cu_qp_delta_coded) {
lc->tu.cu_qp_delta = ff_hevc_cu_qp_delta_abs(s);
if (lc->tu.cu_qp_delta != 0)
@ -805,14 +808,14 @@ static void set_deblocking_bypass(HEVCContext *s, int x0, int y0, int log2_cb_si
int cb_size = 1 << log2_cb_size;
int log2_min_pu_size = s->sps->log2_min_pu_size;
int pic_width_in_min_pu = s->sps->width >> s->sps->log2_min_pu_size;
int min_pu_width = s->sps->width >> s->sps->log2_min_pu_size;
int x_end = FFMIN(x0 + cb_size, s->sps->width);
int y_end = FFMIN(y0 + cb_size, s->sps->height);
int i, j;
for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++)
for (i = (x0 >> log2_min_pu_size); i < (x_end >> log2_min_pu_size); i++)
s->is_pcm[i + j * pic_width_in_min_pu] = 2;
s->is_pcm[i + j * min_pu_width] = 2;
}
static void hls_transform_tree(HEVCContext *s, int x0, int y0, int xBase, int yBase, int cb_xBase, int cb_yBase,
@ -1071,7 +1074,7 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int nPbW, int nP
enum InterPredIdc inter_pred_idc = PRED_L0;
struct MvField current_mv = {{{ 0 }}};
int pic_width_in_min_pu = s->sps->width >> s->sps->log2_min_pu_size;
int min_pu_width = s->sps->width >> s->sps->log2_min_pu_size;
MvField *tab_mvf = s->ref->tab_mvf;
RefPicList *refPicList = s->ref->refPicList;
@ -1104,7 +1107,7 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int nPbW, int nP
for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++)
for (j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++)
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i] = current_mv;
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
} else { /* MODE_INTER */
lc->pu.merge_flag = ff_hevc_merge_flag_decode(s);
if (lc->pu.merge_flag) {
@ -1120,7 +1123,7 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int nPbW, int nP
for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++)
for (j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++)
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i] = current_mv;
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
} else {
ff_hevc_set_neighbour_available(s, x0, y0, nPbW, nPbH);
if (s->sh.slice_type == B_SLICE)
@ -1166,7 +1169,7 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int nPbW, int nP
for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++)
for(j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++)
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i] = current_mv;
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv;
}
}
@ -1319,13 +1322,13 @@ static int luma_intra_pred_mode(HEVCContext *s, int x0, int y0, int pu_size,
HEVCLocalContext *lc = s->HEVClc;
int x_pu = x0 >> s->sps->log2_min_pu_size;
int y_pu = y0 >> s->sps->log2_min_pu_size;
int pic_width_in_min_pu = s->sps->width >> s->sps->log2_min_pu_size;
int min_pu_width = s->sps->width >> s->sps->log2_min_pu_size;
int size_in_pus = pu_size >> s->sps->log2_min_pu_size;
int x0b = x0 & ((1 << s->sps->log2_ctb_size) - 1);
int y0b = y0 & ((1 << s->sps->log2_ctb_size) - 1);
int cand_up = (lc->ctb_up_flag || y0b) ? s->tab_ipm[(y_pu-1)*pic_width_in_min_pu+x_pu] : INTRA_DC ;
int cand_left = (lc->ctb_left_flag || x0b) ? s->tab_ipm[y_pu*pic_width_in_min_pu+x_pu-1] : INTRA_DC ;
int cand_up = (lc->ctb_up_flag || y0b) ? s->tab_ipm[(y_pu-1)*min_pu_width+x_pu] : INTRA_DC ;
int cand_left = (lc->ctb_left_flag || x0b) ? s->tab_ipm[y_pu*min_pu_width+x_pu-1] : INTRA_DC ;
int y_ctb = (y0 >> (s->sps->log2_ctb_size)) << (s->sps->log2_ctb_size);
MvField *tab_mvf = s->ref->tab_mvf;
@ -1380,19 +1383,19 @@ static int luma_intra_pred_mode(HEVCContext *s, int x0, int y0, int pu_size,
if(!size_in_pus)
size_in_pus = 1;
for (i = 0; i < size_in_pus; i++) {
memset(&s->tab_ipm[(y_pu + i) * pic_width_in_min_pu + x_pu],
memset(&s->tab_ipm[(y_pu + i) * min_pu_width + x_pu],
intra_pred_mode, size_in_pus);
for (j = 0; j < size_in_pus; j++) {
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].is_intra = 1;
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].pred_flag[0] = 0;
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].pred_flag[1] = 0;
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].ref_idx[0] = 0;
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].ref_idx[1] = 0;
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].mv[0].x = 0;
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].mv[0].y = 0;
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].mv[1].x = 0;
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + i].mv[1].y = 0;
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].is_intra = 1;
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].pred_flag[0] = 0;
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].pred_flag[1] = 0;
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].ref_idx[0] = 0;
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].ref_idx[1] = 0;
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].mv[0].x = 0;
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].mv[0].y = 0;
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].mv[1].x = 0;
tab_mvf[(y_pu + j) * min_pu_width + x_pu + i].mv[1].y = 0;
}
}
@ -1456,7 +1459,7 @@ static void intra_prediction_unit_default_value(HEVCContext *s, int x0, int y0,
HEVCLocalContext *lc = s->HEVClc;
int pb_size = 1 << log2_cb_size;
int size_in_pus = pb_size >> s->sps->log2_min_pu_size;
int pic_width_in_min_pu = s->sps->width >> s->sps->log2_min_pu_size;
int min_pu_width = s->sps->min_pu_width;
MvField *tab_mvf = s->ref->tab_mvf;
int x_pu = x0 >> s->sps->log2_min_pu_size;
int y_pu = y0 >> s->sps->log2_min_pu_size;
@ -1465,9 +1468,9 @@ static void intra_prediction_unit_default_value(HEVCContext *s, int x0, int y0,
if (size_in_pus == 0)
size_in_pus = 1;
for (j = 0; j < size_in_pus; j++) {
memset(&s->tab_ipm[(y_pu + j) * pic_width_in_min_pu + x_pu], INTRA_DC, size_in_pus);
memset(&s->tab_ipm[(y_pu + j) * min_pu_width + x_pu], INTRA_DC, size_in_pus);
for (k = 0; k < size_in_pus; k++)
tab_mvf[(y_pu + j) * pic_width_in_min_pu + x_pu + k].is_intra = lc->cu.pred_mode == MODE_INTRA;
tab_mvf[(y_pu + j) * min_pu_width + x_pu + k].is_intra = lc->cu.pred_mode == MODE_INTRA;
}
}
@ -1477,7 +1480,7 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
HEVCLocalContext *lc = s->HEVClc;
int log2_min_cb_size = s->sps->log2_min_cb_size;
int length = cb_size >> log2_min_cb_size;
int min_cb_width = s->sps->width >> log2_min_cb_size;
int min_cb_width = s->sps->min_cb_width;
int x_cb = x0 >> log2_min_cb_size;
int y_cb = y0 >> log2_min_cb_size;
int x, y;
@ -1621,14 +1624,16 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
return 0;
}
static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, int log2_cb_size, int cb_depth)
static int hls_coding_quadtree(HEVCContext *s, int x0, int y0,
int log2_cb_size, int cb_depth)
{
HEVCLocalContext *lc = s->HEVClc;
const int cb_size = 1 << log2_cb_size;
int ret;
lc->ct.depth = cb_depth;
if ((x0 + (1 << log2_cb_size) <= s->sps->width) &&
(y0 + (1 << log2_cb_size) <= s->sps->height) &&
if ((x0 + cb_size <= s->sps->width) &&
(y0 + cb_size <= s->sps->height) &&
log2_cb_size > s->sps->log2_min_cb_size) {
SAMPLE(s->split_cu_flag, x0, y0) =
ff_hevc_split_coding_unit_flag_decode(s, cb_depth, x0, y0);
@ -1643,10 +1648,10 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, int log2_cb_size,
}
if (SAMPLE(s->split_cu_flag, x0, y0)) {
const int cb_size_split = cb_size >> 1;
const int x1 = x0 + cb_size_split;
const int y1 = y0 + cb_size_split;
int more_data = 0;
int cb_size = (1 << (log2_cb_size)) >> 1;
int x1 = x0 + cb_size;
int y1 = y0 + cb_size;
more_data = hls_coding_quadtree(s, x0, y0, log2_cb_size - 1, cb_depth + 1);
if (more_data < 0)
@ -1661,20 +1666,20 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, int log2_cb_size,
return hls_coding_quadtree(s, x1, y1, log2_cb_size - 1, cb_depth + 1);
}
if (more_data)
return ((x1 + cb_size) < s->sps->width ||
(y1 + cb_size) < s->sps->height);
return ((x1 + cb_size_split) < s->sps->width ||
(y1 + cb_size_split) < s->sps->height);
else
return 0;
} else {
ret = hls_coding_unit(s, x0, y0, log2_cb_size);
if (ret < 0)
return ret;
if ((!((x0 + (1 << log2_cb_size)) %
if ((!((x0 + cb_size) %
(1 << (s->sps->log2_ctb_size))) ||
(x0 + (1 << log2_cb_size) >= s->sps->width)) &&
(!((y0 + (1 << log2_cb_size)) %
(x0 + cb_size >= s->sps->width)) &&
(!((y0 + cb_size) %
(1 << (s->sps->log2_ctb_size))) ||
(y0 + (1 << log2_cb_size) >= s->sps->height))) {
(y0 + cb_size >= s->sps->height))) {
int end_of_slice_flag = ff_hevc_end_of_slice_flag_decode(s);
return !end_of_slice_flag;
} else {
@ -1685,10 +1690,6 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0, int log2_cb_size,
return 0;
}
/**
* 7.3.4
*/
static void hls_decode_neighbour(HEVCContext *s, int x_ctb, int y_ctb, int ctb_addr_ts)
{
HEVCLocalContext *lc = s->HEVClc;
@ -1703,7 +1704,6 @@ static void hls_decode_neighbour(HEVCContext *s, int x_ctb, int y_ctb, int ctb_a
s->tab_slice_address[ctb_addr_rs] = s->sh.slice_addr;
if (s->pps->entropy_coding_sync_enabled_flag) {
if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
lc->first_qp_group = 1;
@ -1969,13 +1969,11 @@ static int hls_nal_unit(HEVCContext *s)
"nal_unit_type: %d, nuh_layer_id: %dtemporal_id: %d\n",
s->nal_unit_type, nuh_layer_id, s->temporal_id);
return (nuh_layer_id == 0);
return nuh_layer_id == 0;
}
static void restore_tqb_pixels(HEVCContext *s)
{
int pic_width_in_min_pu = s->sps->width >> s->sps->log2_min_pu_size;
int pic_height_in_min_pu = s->sps->height >> s->sps->log2_min_pu_size;
int min_pu_size = 1 << s->sps->log2_min_pu_size;
int x, y, c_idx;
@ -1983,9 +1981,9 @@ static void restore_tqb_pixels(HEVCContext *s)
ptrdiff_t stride = s->frame->linesize[c_idx];
int hshift = s->sps->hshift[c_idx];
int vshift = s->sps->vshift[c_idx];
for (y = 0; y < pic_height_in_min_pu; y++) {
for (x = 0; x < pic_width_in_min_pu; x++) {
if (s->is_pcm[y*pic_width_in_min_pu+x]) {
for (y = 0; y < s->sps->min_pu_height; y++) {
for (x = 0; x < s->sps->min_pu_width; x++) {
if (s->is_pcm[y * s->sps->min_pu_width + x]) {
int n;
int len = min_pu_size >> hshift;
uint8_t *src = &s->frame->data[c_idx][((y << s->sps->log2_min_pu_size) >> vshift) * stride + (((x << s->sps->log2_min_pu_size) >> hshift) << s->sps->pixel_shift)];
@ -2004,16 +2002,12 @@ static void restore_tqb_pixels(HEVCContext *s)
static int hevc_frame_start(HEVCContext *s)
{
HEVCLocalContext *lc = s->HEVClc;
int pic_width_in_min_pu = s->sps->width >> s->sps->log2_min_pu_size;
int pic_height_in_min_pu = s->sps->height >> s->sps->log2_min_pu_size;
int pic_width_in_min_tu = s->sps->width >> s->sps->log2_min_tb_size;
int pic_height_in_min_tu = s->sps->height >> s->sps->log2_min_tb_size;
int ret;
memset(s->horizontal_bs, 0, 2 * s->bs_width * (s->bs_height + 1));
memset(s->vertical_bs, 0, 2 * s->bs_width * (s->bs_height + 1));
memset(s->cbf_luma, 0, pic_width_in_min_tu * pic_height_in_min_tu);
memset(s->is_pcm, 0, pic_width_in_min_pu * pic_height_in_min_pu);
memset(s->cbf_luma, 0, s->sps->min_tb_width * s->sps->min_tb_height);
memset(s->is_pcm, 0, s->sps->min_pu_width * s->sps->min_pu_height);
lc->start_of_tiles_x = 0;
s->is_decoded = 0;
@ -2118,10 +2112,7 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
return ret;
if (s->max_ra == INT_MAX) {
if (s->nal_unit_type == NAL_CRA_NUT ||
s->nal_unit_type == NAL_BLA_W_LP ||
s->nal_unit_type == NAL_BLA_N_LP ||
s->nal_unit_type == NAL_BLA_W_RADL) {
if (s->nal_unit_type == NAL_CRA_NUT || IS_BLA(s)) {
s->max_ra = s->poc;
} else {
if (IS_IDR(s))
@ -2151,8 +2142,8 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
s->sh.slice_type != I_SLICE) {
ret = ff_hevc_slice_rpl(s);
if (ret < 0) {
av_log(s->avctx, AV_LOG_WARNING, "Error constructing the reference "
"lists for the current slice.\n");
av_log(s->avctx, AV_LOG_WARNING,
"Error constructing the reference lists for the current slice.\n");
if (s->avctx->err_recognition & AV_EF_EXPLODE)
return ret;
}
@ -2183,7 +2174,8 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
case NAL_FD_NUT:
break;
default:
av_log(s->avctx, AV_LOG_INFO, "Skipping NAL unit %d\n", s->nal_unit_type);
av_log(s->avctx, AV_LOG_INFO,
"Skipping NAL unit %d\n", s->nal_unit_type);
}
return 0;
@ -2380,7 +2372,8 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
goto fail;
hls_nal_unit(s);
if (s->nal_unit_type == NAL_EOS_NUT || s->nal_unit_type == NAL_EOB_NUT)
if (s->nal_unit_type == NAL_EOS_NUT ||
s->nal_unit_type == NAL_EOB_NUT)
s->eos = 1;
buf += consumed;
@ -2395,7 +2388,8 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
ret = decode_nal_unit(s, s->nals[i].data, s->nals[i].size);
if (ret < 0) {
av_log(s->avctx, AV_LOG_WARNING, "Error parsing NAL unit #%d.\n", i);
av_log(s->avctx, AV_LOG_WARNING,
"Error parsing NAL unit #%d.\n", i);
if (s->avctx->err_recognition & AV_EF_EXPLODE)
goto fail;
}
@ -2762,7 +2756,8 @@ static int hevc_decode_extradata(HEVCContext *s)
// +2 for the nal size field
int nalsize = bytestream2_peek_be16(&gb) + 2;
if (bytestream2_get_bytes_left(&gb) < nalsize) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit size in extradata.\n");
av_log(s->avctx, AV_LOG_ERROR,
"Invalid NAL unit size in extradata.\n");
return AVERROR_INVALIDDATA;
}

View File

@ -656,15 +656,15 @@ int ff_hevc_cu_transquant_bypass_flag_decode(HEVCContext *s)
int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0, int x_cb, int y_cb)
{
int min_cb_width = s->sps->width >> s->sps->log2_min_cb_size;
int min_cb_width = s->sps->min_cb_width;
int inc = 0;
int x0b = x0 & ((1 << s->sps->log2_ctb_size) - 1);
int y0b = y0 & ((1 << s->sps->log2_ctb_size) - 1);
if (s->HEVClc->ctb_left_flag || x0b)
inc = SAMPLE_CTB(s->skip_flag, x_cb-1, y_cb);
inc = !!SAMPLE_CTB(s->skip_flag, x_cb-1, y_cb);
if (s->HEVClc->ctb_up_flag || y0b)
inc += SAMPLE_CTB(s->skip_flag, x_cb, y_cb-1);
inc += !!SAMPLE_CTB(s->skip_flag, x_cb, y_cb-1);
return GET_CABAC(elem_offset[SKIP_FLAG] + inc);
}