Added short-term ref list parameters to allow HM10.0 to decode it properly

This commit is contained in:
Marko Viitanen 2013-05-07 10:36:04 +03:00
parent 8054b8ccb4
commit 3942bbda51
3 changed files with 67 additions and 41 deletions

View file

@ -261,12 +261,6 @@ void encode_one_frame(encoder_control* encoder)
/* output parameters before first frame */
if(encoder->frame == 0)
{
/* Sequence Parameter Set (SPS) */
encode_seq_parameter_set(encoder);
bitstream_align(encoder->stream);
bitstream_flush(encoder->stream);
nal_write(encoder->output, encoder->stream->buffer, encoder->stream->buffer_pos, 0, NAL_SEQ_PARAMETER_SET, 0);
bitstream_clear_buffer(encoder->stream);
/* Video Parameter Set (VPS) */
encode_vid_parameter_set(encoder);
@ -275,6 +269,13 @@ void encode_one_frame(encoder_control* encoder)
nal_write(encoder->output, encoder->stream->buffer, encoder->stream->buffer_pos, 0, NAL_VID_PARAMETER_SET, 0);
bitstream_clear_buffer(encoder->stream);
/* Sequence Parameter Set (SPS) */
encode_seq_parameter_set(encoder);
bitstream_align(encoder->stream);
bitstream_flush(encoder->stream);
nal_write(encoder->output, encoder->stream->buffer, encoder->stream->buffer_pos, 0, NAL_SEQ_PARAMETER_SET, 0);
bitstream_clear_buffer(encoder->stream);
/* Picture Parameter Set (PPS) */
encode_pic_parameter_set(encoder);
bitstream_align(encoder->stream);
@ -298,8 +299,31 @@ void encode_one_frame(encoder_control* encoder)
}
else
{
/* ToDo: add intra/inter search before encoding */
if(0)// (encoder->frame & 0xf) == 0)
{
cabac_start(&cabac);
encoder->in.cur_pic.slicetype = SLICE_I;
encoder->in.cur_pic.type = NAL_IDR_SLICE;
search_slice_data(encoder);
encode_slice_header(encoder);
bitstream_align(encoder->stream);
encode_slice_data(encoder);
cabac_flush(&cabac);
bitstream_align(encoder->stream);
bitstream_flush(encoder->stream);
nal_write(encoder->output, encoder->stream->buffer, encoder->stream->buffer_pos, 0, NAL_IDR_SLICE, 0);
bitstream_clear_buffer(encoder->stream);
}
else
{
/* Picture Parameter Set (PPS) */
encode_pic_parameter_set(encoder);
bitstream_align(encoder->stream);
bitstream_flush(encoder->stream);
nal_write(encoder->output, encoder->stream->buffer, encoder->stream->buffer_pos, 0, NAL_PIC_PARAMETER_SET, 0);
bitstream_clear_buffer(encoder->stream);
/* ToDo: add intra/inter search before encoding */
cabac_start(&cabac);
encoder->in.cur_pic.slicetype = SLICE_I;
encoder->in.cur_pic.type = 0;
@ -310,9 +334,10 @@ void encode_one_frame(encoder_control* encoder)
cabac_flush(&cabac);
bitstream_align(encoder->stream);
bitstream_flush(encoder->stream);
nal_write(encoder->output, encoder->stream->buffer, encoder->stream->buffer_pos, 0, 0, encoder->frame);
nal_write(encoder->output, encoder->stream->buffer, encoder->stream->buffer_pos, 0,0, 0);
bitstream_clear_buffer(encoder->stream);
}
}
#ifdef _DEBUG
/*
{
@ -407,7 +432,7 @@ void encode_PTL(encoder_control *encoder)
WRITE_U(encoder->stream, 0, 5, "XXX_profile_idc[]");
WRITE_U(encoder->stream, 0, 32, "XXX_profile_compatibility_flag[][j]");
WRITE_U(encoder->stream, 0, 1, "general_progressive_source_flag");
WRITE_U(encoder->stream, 1, 1, "general_progressive_source_flag");
WRITE_U(encoder->stream, 0, 1, "general_interlaced_source_flag");
WRITE_U(encoder->stream, 0, 1, "general_non_packed_constraint_flag");
WRITE_U(encoder->stream, 0, 1, "general_frame_only_constraint_flag");
@ -588,7 +613,7 @@ void encode_slice_header(encoder_control* encoder)
WRITE_U(encoder->stream, 1, 1, "first_slice_segment_in_pic_flag");
if(encoder->in.cur_pic.type == NAL_IDR_SLICE)
{
WRITE_U(encoder->stream, 0, 1, "no_output_of_prior_pics_flag");
WRITE_U(encoder->stream, 1, 1, "no_output_of_prior_pics_flag");
}
WRITE_UE(encoder->stream, 0, "slice_pic_parameter_set_id");
@ -610,7 +635,9 @@ void encode_slice_header(encoder_control* encoder)
else
{
WRITE_U(encoder->stream, encoder->frame, 4, "pic_order_cnt_lsb");
WRITE_U(encoder->stream, 1, 1, "short_term_ref_pic_set_sps_flag");
WRITE_U(encoder->stream, 0, 1, "short_term_ref_pic_set_sps_flag");
WRITE_UE(encoder->stream, 0, "num_negative_pics");
WRITE_UE(encoder->stream, 0, "num_positive_pics");
//WRITE_UE(encoder->stream, 0, "short_term_ref_pic_set_idx");
}
//end if
@ -849,7 +876,7 @@ void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, ui
int8_t mpmPred = -1;
int i;
uint32_t flag;
int32_t bestSAD;
//int32_t bestSAD;
uint8_t *base = &encoder->in.cur_pic.yData[xCtb*(LCU_WIDTH>>(MAX_DEPTH)) + (yCtb*(LCU_WIDTH>>(MAX_DEPTH))) *encoder->in.width];
uint8_t *baseU = &encoder->in.cur_pic.uData[xCtb*(LCU_WIDTH>>(MAX_DEPTH+1)) + (yCtb*(LCU_WIDTH>>(MAX_DEPTH+1)))*(encoder->in.width>>1)];
uint8_t *baseV = &encoder->in.cur_pic.vData[xCtb*(LCU_WIDTH>>(MAX_DEPTH+1)) + (yCtb*(LCU_WIDTH>>(MAX_DEPTH+1)))*(encoder->in.width>>1)];
@ -1523,7 +1550,7 @@ void encode_CoeffNxN(encoder_control* encoder,int16_t* coeff, uint8_t width, uin
if( iScanPosSig == scanPosLast )
{
abs_coeff[ 0 ] = abs( coeff[ posLast ] );
coeffSigns = ( coeff[ posLast ] < 0 )?1:0;
coeffSigns = ( coeff[ posLast ] < 0 );
numNonZero = 1;
lastNZPosInCG = iScanPosSig;
firstNZPosInCG = iScanPosSig;
@ -1556,7 +1583,6 @@ void encode_CoeffNxN(encoder_control* encoder,int16_t* coeff, uint8_t width, uin
cabac.ctx = &baseCtx[ uiCtxSig ];
CABAC_BIN(&cabac,uiSig,"significant_coeff_flag");
}
if( uiSig )
{
abs_coeff[ numNonZero ] = abs( coeff[ uiBlkPos ] );
@ -1612,7 +1638,7 @@ void encode_CoeffNxN(encoder_control* encoder,int16_t* coeff, uint8_t width, uin
if (c1 == 0)
{
baseCtxMod = ( type==0 ) ? &g_cCUAbsSCModel_luma[uiCtxSet] : &g_cCUAbsSCModel_chroma[uiCtxSet];
if ( firstC2FlagIdx != -1)
if (firstC2FlagIdx != -1)
{
uint8_t symbol = (abs_coeff[ firstC2FlagIdx ] > 2)?1:0;
cabac.ctx = &baseCtxMod[0];
@ -1620,7 +1646,7 @@ void encode_CoeffNxN(encoder_control* encoder,int16_t* coeff, uint8_t width, uin
}
}
if( beValid && signHidden )
if(beValid && signHidden)
{
CABAC_BINS_EP(&cabac,(coeffSigns >> 1),(numNonZero-1),"");
}

View file

@ -16,7 +16,7 @@
/* CONFIG VARIABLES */
#define LCU_WIDTH 64 /*!< Largest Coding Unit */
#define MAX_SEARCH_DEPTH 3
#define MAX_SEARCH_DEPTH 2
#define MIN_SEARCH_DEPTH 1
#define MAX_DEPTH 3 /*!< smallest CU is LCU_WIDTH>>MAX_DEPTH */