[FFmpeg-cvslog] hevc: move the SliceType enum to hevc.h
Anton Khirnov
git at videolan.org
Fri Mar 24 01:06:09 EET 2017
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Tue Oct 18 21:14:18 2016 +0200| [0bfdcce4d42a6e654c00ea5f9237dc987626457f] | committer: Anton Khirnov
hevc: move the SliceType enum to hevc.h
Those values are decoder-independent and are also use by the VA-API
encoder.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0bfdcce4d42a6e654c00ea5f9237dc987626457f
---
libavcodec/hevc.h | 6 +++++
libavcodec/hevc_cabac.c | 3 ++-
libavcodec/hevc_mvs.c | 9 ++++---
libavcodec/hevc_refs.c | 2 +-
libavcodec/hevcdec.c | 58 +++++++++++++++++++++---------------------
libavcodec/hevcdec.h | 8 +-----
libavcodec/vaapi_encode_h265.c | 20 +++++++--------
7 files changed, 54 insertions(+), 52 deletions(-)
diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index 9536608..bb4f660 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -52,6 +52,12 @@ enum HEVCNALUnitType {
HEVC_NAL_SEI_SUFFIX = 40,
};
+enum HEVCSliceType {
+ HEVC_SLICE_B = 0,
+ HEVC_SLICE_P = 1,
+ HEVC_SLICE_I = 2,
+};
+
/**
* 7.4.2.1
*/
diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index eb16f57..0432330 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -25,6 +25,7 @@
#include "libavutil/common.h"
#include "cabac_functions.h"
+#include "hevc.h"
#include "hevcdec.h"
#define CABAC_MAX_BIN 31
@@ -358,7 +359,7 @@ static void cabac_init_state(HEVCContext *s)
int init_type = 2 - s->sh.slice_type;
int i;
- if (s->sh.cabac_init_flag && s->sh.slice_type != I_SLICE)
+ if (s->sh.cabac_init_flag && s->sh.slice_type != HEVC_SLICE_I)
init_type ^= 3;
for (i = 0; i < HEVC_CONTEXTS; i++) {
diff --git a/libavcodec/hevc_mvs.c b/libavcodec/hevc_mvs.c
index 90aff97..be32e6c 100644
--- a/libavcodec/hevc_mvs.c
+++ b/libavcodec/hevc_mvs.c
@@ -21,6 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "hevc.h"
#include "hevcdec.h"
static const uint8_t l0_l1_cand_idx[12][2] = {
@@ -355,7 +356,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
const int xB2_pu = xB2 >> s->ps.sps->log2_min_pu_size;
const int yB2_pu = yB2 >> s->ps.sps->log2_min_pu_size;
- const int nb_refs = (s->sh.slice_type == P_SLICE) ?
+ const int nb_refs = (s->sh.slice_type == HEVC_SLICE_P) ?
s->sh.nb_refs[0] : FFMIN(s->sh.nb_refs[0], s->sh.nb_refs[1]);
int check_MER = 1;
int check_MER_1 = 1;
@@ -473,7 +474,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
Mv mv_l0_col = { 0 }, mv_l1_col = { 0 };
int available_l0 = temporal_luma_motion_vector(s, x0, y0, nPbW, nPbH,
0, &mv_l0_col, 0);
- int available_l1 = (s->sh.slice_type == B_SLICE) ?
+ int available_l1 = (s->sh.slice_type == HEVC_SLICE_B) ?
temporal_luma_motion_vector(s, x0, y0, nPbW, nPbH,
0, &mv_l1_col, 1) : 0;
@@ -494,7 +495,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
nb_orig_merge_cand = nb_merge_cand;
// combined bi-predictive merge candidates (applies for B slices)
- if (s->sh.slice_type == B_SLICE && nb_orig_merge_cand > 1 &&
+ if (s->sh.slice_type == HEVC_SLICE_B && nb_orig_merge_cand > 1 &&
nb_orig_merge_cand < s->sh.max_num_merge_cand) {
int comb_idx;
@@ -526,7 +527,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
// append Zero motion vector candidates
while (nb_merge_cand < s->sh.max_num_merge_cand) {
mergecandlist[nb_merge_cand].pred_flag[0] = 1;
- mergecandlist[nb_merge_cand].pred_flag[1] = s->sh.slice_type == B_SLICE;
+ mergecandlist[nb_merge_cand].pred_flag[1] = s->sh.slice_type == HEVC_SLICE_B;
AV_ZERO32(mergecandlist[nb_merge_cand].mv + 0);
AV_ZERO32(mergecandlist[nb_merge_cand].mv + 1);
mergecandlist[nb_merge_cand].is_intra = 0;
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index 0b6beb5..30409ba 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -249,7 +249,7 @@ int ff_hevc_slice_rpl(HEVCContext *s)
{
SliceHeader *sh = &s->sh;
- uint8_t nb_list = sh->slice_type == B_SLICE ? 2 : 1;
+ uint8_t nb_list = sh->slice_type == HEVC_SLICE_B ? 2 : 1;
uint8_t list_idx;
int i, j, ret;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 72fdd22..db45608 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -243,7 +243,7 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
s->sh.chroma_offset_l0[i][1] = 0;
}
}
- if (s->sh.slice_type == B_SLICE) {
+ if (s->sh.slice_type == HEVC_SLICE_B) {
for (i = 0; i < s->sh.nb_refs[L1]; i++) {
luma_weight_l1_flag[i] = get_bits1(gb);
if (!luma_weight_l1_flag[i]) {
@@ -520,14 +520,14 @@ static int hls_slice_header(HEVCContext *s)
skip_bits(gb, 1); // slice_reserved_undetermined_flag[]
sh->slice_type = get_ue_golomb_long(gb);
- if (!(sh->slice_type == I_SLICE ||
- sh->slice_type == P_SLICE ||
- sh->slice_type == B_SLICE)) {
+ if (!(sh->slice_type == HEVC_SLICE_I ||
+ sh->slice_type == HEVC_SLICE_P ||
+ sh->slice_type == HEVC_SLICE_B)) {
av_log(s->avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
sh->slice_type);
return AVERROR_INVALIDDATA;
}
- if (IS_IRAP(s) && sh->slice_type != I_SLICE) {
+ if (IS_IRAP(s) && sh->slice_type != HEVC_SLICE_I) {
av_log(s->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n");
return AVERROR_INVALIDDATA;
}
@@ -616,16 +616,16 @@ static int hls_slice_header(HEVCContext *s)
}
sh->nb_refs[L0] = sh->nb_refs[L1] = 0;
- if (sh->slice_type == P_SLICE || sh->slice_type == B_SLICE) {
+ if (sh->slice_type == HEVC_SLICE_P || sh->slice_type == HEVC_SLICE_B) {
int nb_refs;
sh->nb_refs[L0] = s->ps.pps->num_ref_idx_l0_default_active;
- if (sh->slice_type == B_SLICE)
+ if (sh->slice_type == HEVC_SLICE_B)
sh->nb_refs[L1] = s->ps.pps->num_ref_idx_l1_default_active;
if (get_bits1(gb)) { // num_ref_idx_active_override_flag
sh->nb_refs[L0] = get_ue_golomb_long(gb) + 1;
- if (sh->slice_type == B_SLICE)
+ if (sh->slice_type == HEVC_SLICE_B)
sh->nb_refs[L1] = get_ue_golomb_long(gb) + 1;
}
if (sh->nb_refs[L0] > HEVC_MAX_REFS || sh->nb_refs[L1] > HEVC_MAX_REFS) {
@@ -649,7 +649,7 @@ static int hls_slice_header(HEVCContext *s)
sh->list_entry_lx[0][i] = get_bits(gb, av_ceil_log2(nb_refs));
}
- if (sh->slice_type == B_SLICE) {
+ if (sh->slice_type == HEVC_SLICE_B) {
sh->rpl_modification_flag[1] = get_bits1(gb);
if (sh->rpl_modification_flag[1] == 1)
for (i = 0; i < sh->nb_refs[L1]; i++)
@@ -657,7 +657,7 @@ static int hls_slice_header(HEVCContext *s)
}
}
- if (sh->slice_type == B_SLICE)
+ if (sh->slice_type == HEVC_SLICE_B)
sh->mvd_l1_zero_flag = get_bits1(gb);
if (s->ps.pps->cabac_init_present_flag)
@@ -668,7 +668,7 @@ static int hls_slice_header(HEVCContext *s)
sh->collocated_ref_idx = 0;
if (sh->slice_temporal_mvp_enabled_flag) {
sh->collocated_list = L0;
- if (sh->slice_type == B_SLICE)
+ if (sh->slice_type == HEVC_SLICE_B)
sh->collocated_list = !get_bits1(gb);
if (sh->nb_refs[sh->collocated_list] > 1) {
@@ -682,8 +682,8 @@ static int hls_slice_header(HEVCContext *s)
}
}
- if ((s->ps.pps->weighted_pred_flag && sh->slice_type == P_SLICE) ||
- (s->ps.pps->weighted_bipred_flag && sh->slice_type == B_SLICE)) {
+ if ((s->ps.pps->weighted_pred_flag && sh->slice_type == HEVC_SLICE_P) ||
+ (s->ps.pps->weighted_bipred_flag && sh->slice_type == HEVC_SLICE_B)) {
pred_weight_table(s, gb);
}
@@ -1632,7 +1632,7 @@ static void hevc_luma_mv_mpv_mode(HEVCContext *s, int x0, int y0, int nPbW,
int mvp_flag;
ff_hevc_set_neighbour_available(s, x0, y0, nPbW, nPbH);
- if (s->sh.slice_type == B_SLICE)
+ if (s->sh.slice_type == HEVC_SLICE_B)
inter_pred_idc = ff_hevc_inter_pred_idc_decode(s, nPbW, nPbH);
if (inter_pred_idc != PRED_L1) {
@@ -1746,8 +1746,8 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
luma_mc(s, tmp, tmpstride, ref0->frame,
¤t_mv.mv[0], x0, y0, nPbW, nPbH, pred_idx);
- if ((s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) ||
- (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag)) {
+ if ((s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) ||
+ (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag)) {
s->hevcdsp.weighted_pred[pred_idx](s->sh.luma_log2_weight_denom,
s->sh.luma_weight_l0[current_mv.ref_idx[0]],
s->sh.luma_offset_l0[current_mv.ref_idx[0]],
@@ -1759,8 +1759,8 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
chroma_mc(s, tmp, tmp2, tmpstride, ref0->frame,
¤t_mv.mv[0], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2, pred_idx);
- if ((s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) ||
- (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag)) {
+ if ((s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) ||
+ (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag)) {
s->hevcdsp.weighted_pred_chroma[pred_idx](s->sh.chroma_log2_weight_denom,
s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0],
s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0],
@@ -1782,8 +1782,8 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
luma_mc(s, tmp, tmpstride, ref1->frame,
¤t_mv.mv[1], x0, y0, nPbW, nPbH, pred_idx);
- if ((s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) ||
- (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag)) {
+ if ((s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) ||
+ (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag)) {
s->hevcdsp.weighted_pred[pred_idx](s->sh.luma_log2_weight_denom,
s->sh.luma_weight_l1[current_mv.ref_idx[1]],
s->sh.luma_offset_l1[current_mv.ref_idx[1]],
@@ -1796,8 +1796,8 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
chroma_mc(s, tmp, tmp2, tmpstride, ref1->frame,
¤t_mv.mv[1], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2, pred_idx);
- if ((s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) ||
- (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag)) {
+ if ((s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) ||
+ (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag)) {
s->hevcdsp.weighted_pred_chroma[pred_idx](s->sh.chroma_log2_weight_denom,
s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0],
s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0],
@@ -1821,8 +1821,8 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
luma_mc(s, tmp2, tmpstride, ref1->frame,
¤t_mv.mv[1], x0, y0, nPbW, nPbH, pred_idx);
- if ((s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) ||
- (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag)) {
+ if ((s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) ||
+ (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag)) {
s->hevcdsp.weighted_pred_avg[pred_idx](s->sh.luma_log2_weight_denom,
s->sh.luma_weight_l0[current_mv.ref_idx[0]],
s->sh.luma_weight_l1[current_mv.ref_idx[1]],
@@ -1840,8 +1840,8 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
chroma_mc(s, tmp3, tmp4, tmpstride, ref1->frame,
¤t_mv.mv[1], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2, pred_idx);
- if ((s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) ||
- (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag)) {
+ if ((s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) ||
+ (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag)) {
s->hevcdsp.weighted_pred_avg_chroma[pred_idx](s->sh.chroma_log2_weight_denom,
s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0],
s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0],
@@ -2056,7 +2056,7 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
} else
lc->cu.cu_transquant_bypass_flag = 0;
- if (s->sh.slice_type != I_SLICE) {
+ if (s->sh.slice_type != HEVC_SLICE_I) {
uint8_t skip_flag = ff_hevc_skip_flag_decode(s, x0, y0, x_cb, y_cb);
x = y_cb * min_cb_width + x_cb;
@@ -2076,7 +2076,7 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
} else {
int pcm_flag = 0;
- if (s->sh.slice_type != I_SLICE)
+ if (s->sh.slice_type != HEVC_SLICE_I)
lc->cu.pred_mode = ff_hevc_pred_mode_decode(s);
if (lc->cu.pred_mode != MODE_INTRA ||
log2_cb_size == s->ps.sps->log2_min_cb_size) {
@@ -2534,7 +2534,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
}
if (!s->sh.dependent_slice_segment_flag &&
- s->sh.slice_type != I_SLICE) {
+ s->sh.slice_type != HEVC_SLICE_I) {
ret = ff_hevc_slice_rpl(s);
if (ret < 0) {
av_log(s->avctx, AV_LOG_WARNING,
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 78080eb..82adad2 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -85,12 +85,6 @@ enum RPSType {
NB_RPS_TYPE,
};
-enum SliceType {
- B_SLICE = 0,
- P_SLICE = 1,
- I_SLICE = 2,
-};
-
enum SyntaxElement {
SAO_MERGE_FLAG = 0,
SAO_TYPE_IDX,
@@ -242,7 +236,7 @@ typedef struct SliceHeader {
///< address (in raster order) of the first block in the current slice
unsigned int slice_addr;
- enum SliceType slice_type;
+ enum HEVCSliceType slice_type;
int pic_order_cnt_lsb;
diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index ed36ef4..ecf7973 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -25,7 +25,7 @@
#include "libavutil/pixfmt.h"
#include "avcodec.h"
-#include "hevcdec.h"
+#include "hevc.h"
#include "internal.h"
#include "put_bits.h"
#include "vaapi_encode.h"
@@ -630,11 +630,11 @@ static void vaapi_encode_h265_write_slice_header2(PutBitContext *pbc,
}
}
- if (vslice->slice_type == P_SLICE || vslice->slice_type == B_SLICE) {
+ if (vslice->slice_type == HEVC_SLICE_P || vslice->slice_type == HEVC_SLICE_B) {
u(1, vslice_field(num_ref_idx_active_override_flag));
if (vslice->slice_fields.bits.num_ref_idx_active_override_flag) {
ue(vslice_var(num_ref_idx_l0_active_minus1));
- if (vslice->slice_type == B_SLICE) {
+ if (vslice->slice_type == HEVC_SLICE_B) {
ue(vslice_var(num_ref_idx_l1_active_minus1));
}
}
@@ -643,21 +643,21 @@ static void vaapi_encode_h265_write_slice_header2(PutBitContext *pbc,
av_assert0(0);
// ref_pic_lists_modification()
}
- if (vslice->slice_type == B_SLICE) {
+ if (vslice->slice_type == HEVC_SLICE_B) {
u(1, vslice_field(mvd_l1_zero_flag));
}
if (mseq->cabac_init_present_flag) {
u(1, vslice_field(cabac_init_flag));
}
if (vslice->slice_fields.bits.slice_temporal_mvp_enabled_flag) {
- if (vslice->slice_type == B_SLICE)
+ if (vslice->slice_type == HEVC_SLICE_B)
u(1, vslice_field(collocated_from_l0_flag));
ue(vpic->collocated_ref_pic_index, collocated_ref_idx);
}
if ((vpic->pic_fields.bits.weighted_pred_flag &&
- vslice->slice_type == P_SLICE) ||
+ vslice->slice_type == HEVC_SLICE_P) ||
(vpic->pic_fields.bits.weighted_bipred_flag &&
- vslice->slice_type == B_SLICE)) {
+ vslice->slice_type == HEVC_SLICE_B)) {
av_assert0(0);
// pred_weight_table()
}
@@ -1055,13 +1055,13 @@ static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx,
switch (pic->type) {
case PICTURE_TYPE_IDR:
case PICTURE_TYPE_I:
- vslice->slice_type = I_SLICE;
+ vslice->slice_type = HEVC_SLICE_I;
break;
case PICTURE_TYPE_P:
- vslice->slice_type = P_SLICE;
+ vslice->slice_type = HEVC_SLICE_P;
break;
case PICTURE_TYPE_B:
- vslice->slice_type = B_SLICE;
+ vslice->slice_type = HEVC_SLICE_B;
break;
default:
av_assert0(0 && "invalid picture type");
More information about the ffmpeg-cvslog
mailing list