search_info_t *search_from_ident (const graph_ident_t *ident) /* {{{ */ { search_info_t *si; if (ident == NULL) return (NULL); si = malloc (sizeof (*si)); if (si == NULL) return (NULL); memset (si, 0, sizeof (*si)); si->terms = NULL; #define COPY_FIELD(f) do { \ const char *tmp = ident_get_##f (ident); \ if (tmp == NULL) \ si->f = NULL; \ else \ si->f = strdup (tmp); \ } while (0) COPY_FIELD(host); COPY_FIELD(plugin); COPY_FIELD(plugin_instance); COPY_FIELD(type); COPY_FIELD(type_instance); #undef COPY_FIELD return (si); } /* }}} search_info_t *search_from_ident */
static void *lu_create_user_obj (lookup_t *obj, /* {{{ */ data_set_t const *ds, value_list_t const *vl, user_class_t *user_class) { user_obj_t *user_obj; user_obj = malloc (sizeof (*user_obj)); if (user_obj == NULL) { ERROR ("utils_vl_lookup: malloc failed."); return (NULL); } memset (user_obj, 0, sizeof (*user_obj)); user_obj->next = NULL; user_obj->user_obj = obj->cb_user_class (ds, vl, user_class->user_class); if (user_obj->user_obj == NULL) { sfree (user_obj); WARNING("utils_vl_lookup: User-provided constructor failed."); return (NULL); } #define COPY_FIELD(field, group_mask) do { \ if (user_class->match.field.is_regex \ && ((user_class->match.group_by & group_mask) == 0)) \ sstrncpy (user_obj->ident.field, "/.*/", sizeof (user_obj->ident.field)); \ else \ sstrncpy (user_obj->ident.field, vl->field, sizeof (user_obj->ident.field)); \ } while (0) COPY_FIELD (host, LU_GROUP_BY_HOST); COPY_FIELD (plugin, LU_GROUP_BY_PLUGIN); COPY_FIELD (plugin_instance, LU_GROUP_BY_PLUGIN_INSTANCE); COPY_FIELD (type, 0); COPY_FIELD (type_instance, LU_GROUP_BY_TYPE_INSTANCE); #undef COPY_FIELD if (user_class->user_obj_list == NULL) { user_class->user_obj_list = user_obj; } else { user_obj_t *last = user_class->user_obj_list; while (last->next != NULL) last = last->next; last->next = user_obj; } return (user_obj); } /* }}} void *lu_create_user_obj */
static int lu_copy_ident_to_match (identifier_match_t *match, /* {{{ */ identifier_t const *ident, unsigned int group_by) { memset (match, 0, sizeof (*match)); match->group_by = group_by; #define COPY_FIELD(field) do { \ int status = lu_copy_ident_to_match_part (&match->field, ident->field); \ if (status != 0) \ return (status); \ } while (0) COPY_FIELD (host); COPY_FIELD (plugin); COPY_FIELD (plugin_instance); COPY_FIELD (type); COPY_FIELD (type_instance); #undef COPY_FIELD return (0); } /* }}} int lu_copy_ident_to_match */
/* Create a new aggregation instance. */ static agg_instance_t *agg_instance_create (data_set_t const *ds, /* {{{ */ value_list_t const *vl, aggregation_t *agg) { agg_instance_t *inst; DEBUG ("aggregation plugin: Creating new instance."); inst = malloc (sizeof (*inst)); if (inst == NULL) { ERROR ("aggregation plugin: malloc() failed."); return (NULL); } memset (inst, 0, sizeof (*inst)); pthread_mutex_init (&inst->lock, /* attr = */ NULL); inst->ds_type = ds->ds[0].type; #define COPY_FIELD(field, group_mask) do { \ sstrncpy (inst->ident.field, \ (agg->group_by & group_mask) ? vl->field : agg->ident.field, \ sizeof (inst->ident.field)); \ } while (0) COPY_FIELD (host, LU_GROUP_BY_HOST); COPY_FIELD (plugin, LU_GROUP_BY_PLUGIN); COPY_FIELD (plugin_instance, LU_GROUP_BY_PLUGIN_INSTANCE); COPY_FIELD (type, /* group_mask = */ 0); COPY_FIELD (type_instance, LU_GROUP_BY_TYPE_INSTANCE); #undef COPY_FIELD inst->min = NAN; inst->max = NAN; #define INIT_STATE(field) do { \ inst->state_ ## field = NULL; \ if (agg->calc_ ## field) { \ inst->state_ ## field = malloc (sizeof (*inst->state_ ## field)); \ if (inst->state_ ## field == NULL) { \ agg_instance_destroy (inst); \ ERROR ("aggregation plugin: malloc() failed."); \ return (NULL); \ } \ memset (inst->state_ ## field, 0, sizeof (*inst->state_ ## field)); \ } \ } while (0) INIT_STATE (num); INIT_STATE (sum); INIT_STATE (average); INIT_STATE (min); INIT_STATE (max); INIT_STATE (stddev); #undef INIT_STATE pthread_mutex_lock (&agg_instance_list_lock); inst->next = agg_instance_list_head; agg_instance_list_head = inst; pthread_mutex_unlock (&agg_instance_list_lock); return (inst); } /* }}} agg_instance_t *agg_instance_create */
bool VaapiDecoderH264::fillPicture(VaapiPictureH264 * picture, H264SliceHdr * sliceHdr, H264NalUnit * nalu) { uint32_t i, n; H264PPS *const pps = picture->m_pps; H264SPS *const sps = pps->sequence; VaapiDecPicBufLayer *DPBLayer = m_DPBManager->DPBLayer; VaapiBufObject *picParamObj = picture->m_picParam; VAPictureParameterBufferH264 *picParam = (VAPictureParameterBufferH264 *) picParamObj->map(); /* Fill in VAPictureParameterBufferH264 */ vaapiFillPicture(&picParam->CurrPic, picture, 0); for (i = 0, n = 0; i < DPBLayer->DPBCount; i++) { VaapiFrameStore *const frameStore = DPBLayer->DPB[i]; if (frameStore && frameStore->hasReference()) vaapiFillPicture(&picParam->ReferenceFrames[n++], frameStore->m_buffers[0], frameStore->m_structure); } for (; n < N_ELEMENTS(picParam->ReferenceFrames); n++) vaapiInitPicture(&picParam->ReferenceFrames[n]); #define COPY_FIELD(s, f) \ picParam->f = (s)->f #define COPY_BFM(a, s, f) \ picParam->a.bits.f = (s)->f picParam->picture_width_in_mbs_minus1 = m_mbWidth - 1; picParam->picture_height_in_mbs_minus1 = m_mbHeight - 1; picParam->frame_num = m_frameNum; COPY_FIELD(sps, bit_depth_luma_minus8); COPY_FIELD(sps, bit_depth_chroma_minus8); COPY_FIELD(sps, num_ref_frames); COPY_FIELD(pps, num_slice_groups_minus1); COPY_FIELD(pps, slice_group_map_type); COPY_FIELD(pps, slice_group_change_rate_minus1); COPY_FIELD(pps, pic_init_qp_minus26); COPY_FIELD(pps, pic_init_qs_minus26); COPY_FIELD(pps, chroma_qp_index_offset); COPY_FIELD(pps, second_chroma_qp_index_offset); picParam->seq_fields.value = 0; /* reset all bits */ picParam->seq_fields.bits.residual_colour_transform_flag = sps->separate_colour_plane_flag; picParam->seq_fields.bits.MinLumaBiPredSize8x8 = sps->level_idc >= 31; /* A.3.3.2 */ COPY_BFM(seq_fields, sps, chroma_format_idc); COPY_BFM(seq_fields, sps, gaps_in_frame_num_value_allowed_flag); COPY_BFM(seq_fields, sps, frame_mbs_only_flag); COPY_BFM(seq_fields, sps, mb_adaptive_frame_field_flag); COPY_BFM(seq_fields, sps, direct_8x8_inference_flag); COPY_BFM(seq_fields, sps, log2_max_frame_num_minus4); COPY_BFM(seq_fields, sps, pic_order_cnt_type); COPY_BFM(seq_fields, sps, log2_max_pic_order_cnt_lsb_minus4); COPY_BFM(seq_fields, sps, delta_pic_order_always_zero_flag); picParam->pic_fields.value = 0; /* reset all bits */ picParam->pic_fields.bits.field_pic_flag = sliceHdr->field_pic_flag; picParam->pic_fields.bits.reference_pic_flag = VAAPI_PICTURE_IS_REFERENCE(picture); COPY_BFM(pic_fields, pps, entropy_coding_mode_flag); COPY_BFM(pic_fields, pps, weighted_pred_flag); COPY_BFM(pic_fields, pps, weighted_bipred_idc); COPY_BFM(pic_fields, pps, transform_8x8_mode_flag); COPY_BFM(pic_fields, pps, constrained_intra_pred_flag); COPY_BFM(pic_fields, pps, pic_order_present_flag); COPY_BFM(pic_fields, pps, deblocking_filter_control_present_flag); COPY_BFM(pic_fields, pps, redundant_pic_cnt_present_flag); picParamObj->unmap(); return true; }
static BOOL ME_SetParaFormat(ME_TextEditor *editor, ME_DisplayItem *para, const PARAFORMAT2 *pFmt) { PARAFORMAT2 copy; DWORD dwMask; assert(para->member.para.pFmt->cbSize == sizeof(PARAFORMAT2)); dwMask = pFmt->dwMask; if (pFmt->cbSize < sizeof(PARAFORMAT)) return FALSE; else if (pFmt->cbSize < sizeof(PARAFORMAT2)) dwMask &= PFM_ALL; else dwMask &= PFM_ALL2; add_undo_set_para_fmt( editor, ¶->member.para ); copy = *para->member.para.pFmt; #define COPY_FIELD(m, f) \ if (dwMask & (m)) { \ para->member.para.pFmt->dwMask |= m; \ para->member.para.pFmt->f = pFmt->f; \ } COPY_FIELD(PFM_NUMBERING, wNumbering); COPY_FIELD(PFM_STARTINDENT, dxStartIndent); if (dwMask & PFM_OFFSETINDENT) para->member.para.pFmt->dxStartIndent += pFmt->dxStartIndent; COPY_FIELD(PFM_RIGHTINDENT, dxRightIndent); COPY_FIELD(PFM_OFFSET, dxOffset); COPY_FIELD(PFM_ALIGNMENT, wAlignment); if (dwMask & PFM_TABSTOPS) { para->member.para.pFmt->cTabCount = pFmt->cTabCount; memcpy(para->member.para.pFmt->rgxTabs, pFmt->rgxTabs, pFmt->cTabCount*sizeof(LONG)); } #define EFFECTS_MASK (PFM_RTLPARA|PFM_KEEP|PFM_KEEPNEXT|PFM_PAGEBREAKBEFORE| \ PFM_NOLINENUMBER|PFM_NOWIDOWCONTROL|PFM_DONOTHYPHEN|PFM_SIDEBYSIDE| \ PFM_TABLE) /* we take for granted that PFE_xxx is the hiword of the corresponding PFM_xxx */ if (dwMask & EFFECTS_MASK) { para->member.para.pFmt->dwMask |= dwMask & EFFECTS_MASK; para->member.para.pFmt->wEffects &= ~HIWORD(dwMask); para->member.para.pFmt->wEffects |= pFmt->wEffects & HIWORD(dwMask); } #undef EFFECTS_MASK COPY_FIELD(PFM_SPACEBEFORE, dySpaceBefore); COPY_FIELD(PFM_SPACEAFTER, dySpaceAfter); COPY_FIELD(PFM_LINESPACING, dyLineSpacing); COPY_FIELD(PFM_STYLE, sStyle); COPY_FIELD(PFM_LINESPACING, bLineSpacingRule); COPY_FIELD(PFM_SHADING, wShadingWeight); COPY_FIELD(PFM_SHADING, wShadingStyle); COPY_FIELD(PFM_NUMBERINGSTART, wNumberingStart); COPY_FIELD(PFM_NUMBERINGSTYLE, wNumberingStyle); COPY_FIELD(PFM_NUMBERINGTAB, wNumberingTab); COPY_FIELD(PFM_BORDER, wBorderSpace); COPY_FIELD(PFM_BORDER, wBorderWidth); COPY_FIELD(PFM_BORDER, wBorders); para->member.para.pFmt->dwMask |= dwMask; #undef COPY_FIELD if (memcmp(©, para->member.para.pFmt, sizeof(PARAFORMAT2))) para->member.para.nFlags |= MEPF_REWRAP; return TRUE; }
static int agg_instance_create_name (agg_instance_t *inst, /* {{{ */ value_list_t const *vl, aggregation_t const *agg) { #define COPY_FIELD(buffer, buffer_size, field, group_mask, all_value) do { \ if (agg->set_ ## field != NULL) \ sstrncpy (buffer, agg->set_ ## field, buffer_size); \ else if ((agg->regex_fields & group_mask) \ && (agg->group_by & group_mask)) \ sstrncpy (buffer, vl->field, buffer_size); \ else if ((agg->regex_fields & group_mask) \ && (AGG_MATCHES_ALL (agg->ident.field))) \ sstrncpy (buffer, all_value, buffer_size); \ else \ sstrncpy (buffer, agg->ident.field, buffer_size); \ } while (0) /* Host */ COPY_FIELD (inst->ident.host, sizeof (inst->ident.host), host, LU_GROUP_BY_HOST, "global"); /* Plugin */ if (agg->set_plugin != NULL) sstrncpy (inst->ident.plugin, agg->set_plugin, sizeof (inst->ident.plugin)); else sstrncpy (inst->ident.plugin, "aggregation", sizeof (inst->ident.plugin)); /* Plugin instance */ if (agg->set_plugin_instance != NULL) sstrncpy (inst->ident.plugin_instance, agg->set_plugin_instance, sizeof (inst->ident.plugin_instance)); else { char tmp_plugin[DATA_MAX_NAME_LEN]; char tmp_plugin_instance[DATA_MAX_NAME_LEN] = ""; if ((agg->regex_fields & LU_GROUP_BY_PLUGIN) && (agg->group_by & LU_GROUP_BY_PLUGIN)) sstrncpy (tmp_plugin, vl->plugin, sizeof (tmp_plugin)); else if ((agg->regex_fields & LU_GROUP_BY_PLUGIN) && (AGG_MATCHES_ALL (agg->ident.plugin))) sstrncpy (tmp_plugin, "", sizeof (tmp_plugin)); else sstrncpy (tmp_plugin, agg->ident.plugin, sizeof (tmp_plugin)); if ((agg->regex_fields & LU_GROUP_BY_PLUGIN_INSTANCE) && (agg->group_by & LU_GROUP_BY_PLUGIN_INSTANCE)) sstrncpy (tmp_plugin_instance, vl->plugin_instance, sizeof (tmp_plugin_instance)); else if ((agg->regex_fields & LU_GROUP_BY_PLUGIN_INSTANCE) && (AGG_MATCHES_ALL (agg->ident.plugin_instance))) sstrncpy (tmp_plugin_instance, "", sizeof (tmp_plugin_instance)); else sstrncpy (tmp_plugin_instance, agg->ident.plugin_instance, sizeof (tmp_plugin_instance)); if ((strcmp ("", tmp_plugin) == 0) && (strcmp ("", tmp_plugin_instance) == 0)) sstrncpy (inst->ident.plugin_instance, AGG_FUNC_PLACEHOLDER, sizeof (inst->ident.plugin_instance)); else if (strcmp ("", tmp_plugin) != 0) ssnprintf (inst->ident.plugin_instance, sizeof (inst->ident.plugin_instance), "%s-%s", tmp_plugin, AGG_FUNC_PLACEHOLDER); else if (strcmp ("", tmp_plugin_instance) != 0) ssnprintf (inst->ident.plugin_instance, sizeof (inst->ident.plugin_instance), "%s-%s", tmp_plugin_instance, AGG_FUNC_PLACEHOLDER); else ssnprintf (inst->ident.plugin_instance, sizeof (inst->ident.plugin_instance), "%s-%s-%s", tmp_plugin, tmp_plugin_instance, AGG_FUNC_PLACEHOLDER); } /* Type */ sstrncpy (inst->ident.type, agg->ident.type, sizeof (inst->ident.type)); /* Type instance */ COPY_FIELD (inst->ident.type_instance, sizeof (inst->ident.type_instance), type_instance, LU_GROUP_BY_TYPE_INSTANCE, ""); #undef COPY_FIELD return (0); } /* }}} int agg_instance_create_name */