Commit 0bfdcce4 authored by Anton Khirnov's avatar Anton Khirnov

hevc: move the SliceType enum to hevc.h

Those values are decoder-independent and are also use by the VA-API
encoder.
parent 096a8eff
......@@ -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
*/
......
......@@ -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++) {
......
......@@ -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;
......
......@@ -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;
......
This diff is collapsed.
......@@ -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;
......
......@@ -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");
......
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