static void pred_weight_table( h264_decoder* dec_params) { Slice *currSlice = dec_params->img->currentSlice; DataPartition *partition = &(currSlice->partArr[0]); Bitstream *currStream = partition->bitstream; int luma_weight_flag_l0, luma_weight_flag_l1, chroma_weight_flag_l0, chroma_weight_flag_l1; int i,j; dec_params->img->luma_log2_weight_denom = ue_v ("SH: luma_log2_weight_denom", currStream,dec_params); dec_params->img->wp_round_luma = dec_params->img->luma_log2_weight_denom ? 1<<(dec_params->img->luma_log2_weight_denom - 1): 0; dec_params->img->chroma_log2_weight_denom = ue_v ("SH: chroma_log2_weight_denom", currStream,dec_params); dec_params->img->wp_round_chroma = dec_params->img->chroma_log2_weight_denom ? 1<<(dec_params->img->chroma_log2_weight_denom - 1): 0; reset_wp_params(dec_params->img); for (i=0; i<dec_params->img->num_ref_idx_l0_active; i++) { luma_weight_flag_l0 = u_1("SH: luma_weight_flag_l0", currStream,dec_params); if (luma_weight_flag_l0) { dec_params->img->apply_weights_luma = 1; dec_params->img->wp_weight[0][i][0] = se_v ("SH: luma_weight_l0", currStream,dec_params); dec_params->img->wp_offset[0][i][0] = se_v ("SH: luma_offset_l0", currStream,dec_params); } else { dec_params->img->wp_weight[0][i][0] = 1<<dec_params->img->luma_log2_weight_denom; dec_params->img->wp_offset[0][i][0] = 0; } //if (dec_params->active_sps->chroma_format_idc != 0) { chroma_weight_flag_l0 = u_1 ("SH: chroma_weight_flag_l0", currStream,dec_params); for (j=1; j<3; j++) { if (chroma_weight_flag_l0) { dec_params->img->wp_weight[0][i][j] = se_v("SH: chroma_weight_l0", currStream,dec_params); dec_params->img->wp_offset[0][i][j] = se_v("SH: chroma_offset_l0", currStream,dec_params); dec_params->img->apply_weights_chr = 1; } else { dec_params->img->wp_weight[0][i][j] = 1<<dec_params->img->chroma_log2_weight_denom; dec_params->img->wp_offset[0][i][j] = 0; } } } } if ((dec_params->img->type == B_SLICE) && dec_params->active_pps->weighted_bipred_idc == 1) { for (i=0; i<dec_params->img->num_ref_idx_l1_active; i++) { luma_weight_flag_l1 = u_1("SH: luma_weight_flag_l1", currStream,dec_params); if (luma_weight_flag_l1) { dec_params->img->wp_weight[1][i][0] = se_v ("SH: luma_weight_l1", currStream,dec_params); dec_params->img->wp_offset[1][i][0] = se_v ("SH: luma_offset_l1", currStream,dec_params); dec_params->img->apply_weights_luma =1; } else { dec_params->img->wp_weight[1][i][0] = 1<<dec_params->img->luma_log2_weight_denom; dec_params->img->wp_offset[1][i][0] = 0; } //if (dec_params->active_sps->chroma_format_idc != 0) { chroma_weight_flag_l1 = u_1 ("SH: chroma_weight_flag_l1", currStream,dec_params); for (j=1; j<3; j++) { if (chroma_weight_flag_l1) { dec_params->img->wp_weight[1][i][j] = se_v("SH: chroma_weight_l1", currStream,dec_params); dec_params->img->wp_offset[1][i][j] = se_v("SH: chroma_offset_l1", currStream,dec_params); dec_params->img->apply_weights_chr = 1; } else { dec_params->img->wp_weight[1][i][j] = 1<<dec_params->img->chroma_log2_weight_denom; dec_params->img->wp_offset[1][i][j] = 0; } } } } } }
/*! ************************************************************************ * \brief * read the weighted prediction tables ************************************************************************ */ static void pred_weight_table(Slice *currSlice) { VideoParameters *p_Vid = currSlice->p_Vid; seq_parameter_set_rbsp_t *active_sps = p_Vid->active_sps; byte dP_nr = assignSE2partition[currSlice->dp_mode][SE_HEADER]; DataPartition *partition = &(currSlice->partArr[dP_nr]); Bitstream *currStream = partition->bitstream; int luma_weight_flag_l0, luma_weight_flag_l1, chroma_weight_flag_l0, chroma_weight_flag_l1; int i,j; currSlice->luma_log2_weight_denom = (unsigned short) ue_v ("SH: luma_log2_weight_denom", currStream); currSlice->wp_round_luma = currSlice->luma_log2_weight_denom ? 1<<(currSlice->luma_log2_weight_denom - 1): 0; if ( 0 != active_sps->chroma_format_idc) { currSlice->chroma_log2_weight_denom = (unsigned short) ue_v ("SH: chroma_log2_weight_denom", currStream); currSlice->wp_round_chroma = currSlice->chroma_log2_weight_denom ? 1<<(currSlice->chroma_log2_weight_denom - 1): 0; } reset_wp_params(currSlice); for (i=0; i<currSlice->num_ref_idx_active[LIST_0]; i++) { luma_weight_flag_l0 = u_1("SH: luma_weight_flag_l0", currStream); if (luma_weight_flag_l0) { currSlice->wp_weight[0][i][0] = se_v ("SH: luma_weight_l0", currStream); currSlice->wp_offset[0][i][0] = se_v ("SH: luma_offset_l0", currStream); currSlice->wp_offset[0][i][0] = currSlice->wp_offset[0][i][0]<<(p_Vid->bitdepth_luma - 8); } else { currSlice->wp_weight[0][i][0] = 1 << currSlice->luma_log2_weight_denom; currSlice->wp_offset[0][i][0] = 0; } if (active_sps->chroma_format_idc != 0) { chroma_weight_flag_l0 = u_1 ("SH: chroma_weight_flag_l0", currStream); for (j=1; j<3; j++) { if (chroma_weight_flag_l0) { currSlice->wp_weight[0][i][j] = se_v("SH: chroma_weight_l0", currStream); currSlice->wp_offset[0][i][j] = se_v("SH: chroma_offset_l0", currStream); currSlice->wp_offset[0][i][j] = currSlice->wp_offset[0][i][j]<<(p_Vid->bitdepth_chroma-8); } else { currSlice->wp_weight[0][i][j] = 1<<currSlice->chroma_log2_weight_denom; currSlice->wp_offset[0][i][j] = 0; } } } } if ((p_Vid->type == B_SLICE) && p_Vid->active_pps->weighted_bipred_idc == 1) { for (i=0; i<currSlice->num_ref_idx_active[LIST_1]; i++) { luma_weight_flag_l1 = u_1("SH: luma_weight_flag_l1", currStream); if (luma_weight_flag_l1) { currSlice->wp_weight[1][i][0] = se_v ("SH: luma_weight_l1", currStream); currSlice->wp_offset[1][i][0] = se_v ("SH: luma_offset_l1", currStream); currSlice->wp_offset[1][i][0] = currSlice->wp_offset[1][i][0]<<(p_Vid->bitdepth_luma-8); } else { currSlice->wp_weight[1][i][0] = 1<<currSlice->luma_log2_weight_denom; currSlice->wp_offset[1][i][0] = 0; } if (active_sps->chroma_format_idc != 0) { chroma_weight_flag_l1 = u_1 ("SH: chroma_weight_flag_l1", currStream); for (j=1; j<3; j++) { if (chroma_weight_flag_l1) { currSlice->wp_weight[1][i][j] = se_v("SH: chroma_weight_l1", currStream); currSlice->wp_offset[1][i][j] = se_v("SH: chroma_offset_l1", currStream); currSlice->wp_offset[1][i][j] = currSlice->wp_offset[1][i][j]<<(p_Vid->bitdepth_chroma-8); } else { currSlice->wp_weight[1][i][j] = 1<<currSlice->chroma_log2_weight_denom; currSlice->wp_offset[1][i][j] = 0; } } } } } }
/*! ************************************************************************ * \brief * read the weighted prediction tables ************************************************************************ */ static void pred_weight_table() { Slice *currSlice = img->currentSlice; int dP_nr = assignSE2partition[currSlice->dp_mode][SE_HEADER]; DataPartition *partition = &(currSlice->partArr[dP_nr]); Bitstream *currStream = partition->bitstream; int luma_weight_flag_l0, luma_weight_flag_l1, chroma_weight_flag_l0, chroma_weight_flag_l1; int i,j; img->luma_log2_weight_denom = ue_v ("SH: luma_log2_weight_denom", currStream); img->wp_round_luma = img->luma_log2_weight_denom ? 1<<(img->luma_log2_weight_denom - 1): 0; if ( 0 != active_sps->chroma_format_idc) { img->chroma_log2_weight_denom = ue_v ("SH: chroma_log2_weight_denom", currStream); img->wp_round_chroma = img->chroma_log2_weight_denom ? 1<<(img->chroma_log2_weight_denom - 1): 0; } reset_wp_params(img); for (i=0; i<img->num_ref_idx_l0_active; i++) { luma_weight_flag_l0 = u_1("SH: luma_weight_flag_l0", currStream); if (luma_weight_flag_l0) { img->wp_weight[0][i][0] = se_v ("SH: luma_weight_l0", currStream); img->wp_offset[0][i][0] = se_v ("SH: luma_offset_l0", currStream); } else { img->wp_weight[0][i][0] = 1<<img->luma_log2_weight_denom; img->wp_offset[0][i][0] = 0; } if (active_sps->chroma_format_idc != 0) { chroma_weight_flag_l0 = u_1 ("SH: chroma_weight_flag_l0", currStream); for (j=1; j<3; j++) { if (chroma_weight_flag_l0) { img->wp_weight[0][i][j] = se_v("SH: chroma_weight_l0", currStream); img->wp_offset[0][i][j] = se_v("SH: chroma_offset_l0", currStream); } else { img->wp_weight[0][i][j] = 1<<img->chroma_log2_weight_denom; img->wp_offset[0][i][j] = 0; } } } } if ((img->type == B_SLICE) && active_pps->weighted_bipred_idc == 1) { for (i=0; i<img->num_ref_idx_l1_active; i++) { luma_weight_flag_l1 = u_1("SH: luma_weight_flag_l1", currStream); if (luma_weight_flag_l1) { img->wp_weight[1][i][0] = se_v ("SH: luma_weight_l1", currStream); img->wp_offset[1][i][0] = se_v ("SH: luma_offset_l1", currStream); } else { img->wp_weight[1][i][0] = 1<<img->luma_log2_weight_denom; img->wp_offset[1][i][0] = 0; } if (active_sps->chroma_format_idc != 0) { chroma_weight_flag_l1 = u_1 ("SH: chroma_weight_flag_l1", currStream); for (j=1; j<3; j++) { if (chroma_weight_flag_l1) { img->wp_weight[1][i][j] = se_v("SH: chroma_weight_l1", currStream); img->wp_offset[1][i][j] = se_v("SH: chroma_offset_l1", currStream); } else { img->wp_weight[1][i][j] = 1<<img->chroma_log2_weight_denom; img->wp_offset[1][i][j] = 0; } } } } } }