diff options
author | James Almer <jamrial@gmail.com> | 2017-03-23 20:02:11 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2017-03-23 20:02:11 -0300 |
commit | dc39ccdc3b88e9ec3b4aa3581798c30660d94d07 (patch) | |
tree | ea6dd9bc79af60d63fe0edd905158b3440db23d4 /libavcodec | |
parent | 0f4abbd4ee1c5b34068cb48ceab3515641d6e0fb (diff) | |
parent | 0bfdcce4d42a6e654c00ea5f9237dc987626457f (diff) | |
download | ffmpeg-dc39ccdc3b88e9ec3b4aa3581798c30660d94d07.tar.gz |
Merge commit '0bfdcce4d42a6e654c00ea5f9237dc987626457f'
* commit '0bfdcce4d42a6e654c00ea5f9237dc987626457f':
hevc: move the SliceType enum to hevc.h
Merged-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/hevc.h | 6 | ||||
-rw-r--r-- | libavcodec/hevc_cabac.c | 3 | ||||
-rw-r--r-- | libavcodec/hevc_mvs.c | 9 | ||||
-rw-r--r-- | libavcodec/hevc_parser.c | 8 | ||||
-rw-r--r-- | libavcodec/hevc_refs.c | 2 | ||||
-rw-r--r-- | libavcodec/hevcdec.c | 50 | ||||
-rw-r--r-- | libavcodec/hevcdec.h | 8 | ||||
-rw-r--r-- | libavcodec/vaapi_encode_h265.c | 20 | ||||
-rw-r--r-- | libavcodec/vaapi_hevc.c | 14 |
9 files changed, 61 insertions, 59 deletions
diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h index 4237b80f81..de77d2ac43 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 205fc4edef..e27c54ed4b 100644 --- a/libavcodec/hevc_cabac.c +++ b/libavcodec/hevc_cabac.c @@ -26,6 +26,7 @@ #include "cabac_functions.h" #include "hevc_data.h" +#include "hevc.h" #include "hevcdec.h" #define CABAC_MAX_BIN 31 @@ -481,7 +482,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 edad491406..a8f7876b59 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] = { @@ -315,7 +316,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0, const int xB2 = x0 - 1; const int yB2 = y0 - 1; - 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 zero_idx = 0; @@ -411,7 +412,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; @@ -430,7 +431,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 = 0; @@ -459,7 +460,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 = PF_L0 + ((s->sh.slice_type == B_SLICE) << 1); + mergecandlist[nb_merge_cand].pred_flag = PF_L0 + ((s->sh.slice_type == HEVC_SLICE_B) << 1); AV_ZERO32(mergecandlist[nb_merge_cand].mv + 0); AV_ZERO32(mergecandlist[nb_merge_cand].mv + 1); mergecandlist[nb_merge_cand].ref_idx[0] = zero_idx < nb_refs ? zero_idx : 0; diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c index 2a5190dcb8..310428d0ff 100644 --- a/libavcodec/hevc_parser.c +++ b/libavcodec/hevc_parser.c @@ -360,14 +360,14 @@ static inline int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, skip_bits(gb, 1); // slice_reserved_undetermined_flag[] sh->slice_type = get_ue_golomb(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(avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n", sh->slice_type); return AVERROR_INVALIDDATA; } - s->pict_type = sh->slice_type == B_SLICE ? AV_PICTURE_TYPE_B : - sh->slice_type == P_SLICE ? AV_PICTURE_TYPE_P : + s->pict_type = sh->slice_type == HEVC_SLICE_B ? AV_PICTURE_TYPE_B : + sh->slice_type == HEVC_SLICE_P ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; if (ps->pps->output_flag_present_flag) diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c index 935e388653..9103c84686 100644 --- a/libavcodec/hevc_refs.c +++ b/libavcodec/hevc_refs.c @@ -300,7 +300,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 92897f42f8..98ed2a022b 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -192,7 +192,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]) { @@ -510,14 +510,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; } @@ -608,16 +608,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) { @@ -641,7 +641,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++) @@ -649,7 +649,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) @@ -660,7 +660,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) { @@ -674,8 +674,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); } @@ -1347,8 +1347,8 @@ static void luma_mc_uni(HEVCContext *s, uint8_t *dst, ptrdiff_t dststride, int pic_height = s->ps.sps->height; int mx = mv->x & 3; int my = mv->y & 3; - int weight_flag = (s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) || - (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag); + int weight_flag = (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); int idx = ff_hevc_pel_weight[block_w]; x_off += mv->x >> 2; @@ -1410,8 +1410,8 @@ static void luma_mc_uni(HEVCContext *s, uint8_t *dst, ptrdiff_t dststride, int my0 = mv0->y & 3; int mx1 = mv1->x & 3; int my1 = mv1->y & 3; - int weight_flag = (s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) || - (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag); + int weight_flag = (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); int x_off0 = x_off + (mv0->x >> 2); int y_off0 = y_off + (mv0->y >> 2); int x_off1 = x_off + (mv1->x >> 2); @@ -1496,8 +1496,8 @@ static void chroma_mc_uni(HEVCContext *s, uint8_t *dst0, int pic_width = s->ps.sps->width >> s->ps.sps->hshift[1]; int pic_height = s->ps.sps->height >> s->ps.sps->vshift[1]; const Mv *mv = ¤t_mv->mv[reflist]; - int weight_flag = (s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) || - (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag); + int weight_flag = (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); int idx = ff_hevc_pel_weight[block_w]; int hshift = s->ps.sps->hshift[1]; int vshift = s->ps.sps->vshift[1]; @@ -1561,8 +1561,8 @@ static void chroma_mc_bi(HEVCContext *s, uint8_t *dst0, ptrdiff_t dststride, AVF uint8_t *src2 = ref1->data[cidx+1]; ptrdiff_t src1stride = ref0->linesize[cidx+1]; ptrdiff_t src2stride = ref1->linesize[cidx+1]; - int weight_flag = (s->sh.slice_type == P_SLICE && s->ps.pps->weighted_pred_flag) || - (s->sh.slice_type == B_SLICE && s->ps.pps->weighted_bipred_flag); + int weight_flag = (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); int pic_width = s->ps.sps->width >> s->ps.sps->hshift[1]; int pic_height = s->ps.sps->height >> s->ps.sps->vshift[1]; Mv *mv0 = ¤t_mv->mv[0]; @@ -1662,7 +1662,7 @@ static void hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW, ff_hevc_set_neighbour_available(s, x0, y0, nPbW, nPbH); mv->pred_flag = 0; - 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) { @@ -2040,7 +2040,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; @@ -2066,7 +2066,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) { @@ -2806,7 +2806,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 b6391eace8..0c7881286c 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -87,12 +87,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, @@ -258,7 +252,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 754eb064a0..6e008b7b9c 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"); diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c index 6dd35db19e..69b8e478c6 100644 --- a/libavcodec/vaapi_hevc.c +++ b/libavcodec/vaapi_hevc.c @@ -297,9 +297,9 @@ static void fill_pred_weight_table(const HEVCContext *h, slice_param->delta_chroma_log2_weight_denom = 0; slice_param->luma_log2_weight_denom = 0; - if (sh->slice_type == I_SLICE || - (sh->slice_type == P_SLICE && !h->ps.pps->weighted_pred_flag) || - (sh->slice_type == B_SLICE && !h->ps.pps->weighted_bipred_flag)) + if (sh->slice_type == HEVC_SLICE_I || + (sh->slice_type == HEVC_SLICE_P && !h->ps.pps->weighted_pred_flag) || + (sh->slice_type == HEVC_SLICE_B && !h->ps.pps->weighted_bipred_flag)) return; slice_param->luma_log2_weight_denom = sh->luma_log2_weight_denom; @@ -317,7 +317,7 @@ static void fill_pred_weight_table(const HEVCContext *h, slice_param->ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1]; } - if (sh->slice_type == B_SLICE) { + if (sh->slice_type == HEVC_SLICE_B) { for (i = 0; i < 15 && i < sh->nb_refs[L1]; i++) { slice_param->delta_luma_weight_l1[i] = sh->luma_weight_l1[i] - (1 << sh->luma_log2_weight_denom); slice_param->luma_offset_l1[i] = sh->luma_offset_l1[i]; @@ -356,8 +356,8 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx, const SliceHeader *sh = &h->sh; VAAPIDecodePictureHEVC *pic = h->ref->hwaccel_picture_private; - int nb_list = (sh->slice_type == B_SLICE) ? - 2 : (sh->slice_type == I_SLICE ? 0 : 1); + int nb_list = (sh->slice_type == HEVC_SLICE_B) ? + 2 : (sh->slice_type == HEVC_SLICE_I ? 0 : 1); int err, i, list_idx; @@ -387,7 +387,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx, .slice_beta_offset_div2 = sh->beta_offset / 2, .slice_tc_offset_div2 = sh->tc_offset / 2, .collocated_ref_idx = sh->slice_temporal_mvp_enabled_flag ? sh->collocated_ref_idx : 0xFF, - .five_minus_max_num_merge_cand = sh->slice_type == I_SLICE ? 0 : 5 - sh->max_num_merge_cand, + .five_minus_max_num_merge_cand = sh->slice_type == HEVC_SLICE_I ? 0 : 5 - sh->max_num_merge_cand, .num_ref_idx_l0_active_minus1 = sh->nb_refs[L0] ? sh->nb_refs[L0] - 1 : 0, .num_ref_idx_l1_active_minus1 = sh->nb_refs[L1] ? sh->nb_refs[L1] - 1 : 0, |