Example #1
0
void CCoder::ReadGoodBacks()
{
  UINT32 aGoodIndex;
  if (m_NumPasses > 1)
  {
    aGoodIndex = m_FinderPos % kNumGoodBacks;
    m_MatchDistances = m_OnePosMatchesArray[aGoodIndex].MatchDistances;
  }
  UINT32 aDistanceTmp[kMatchMaxLen + 1];
  UINT32 aLen = m_MatchFinder.GetLongestMatch(aDistanceTmp);
  for(UINT32 i = kMatchMinLen; i <= aLen; i++)
    m_MatchDistances[i] = aDistanceTmp[i];

  m_LongestMatchDistance = m_MatchDistances[aLen];
  if (aLen == m_NumFastBytes && m_NumFastBytes != kMatchMaxLen)
    m_LongestMatchLength = aLen + m_MatchFinder.GetMatchLen(aLen, 
        m_LongestMatchDistance, kMatchMaxLen - aLen);
  else
    m_LongestMatchLength = aLen;
  if (m_NumPasses > 1)
  {
    m_OnePosMatchesArray[aGoodIndex].LongestMatchDistance = UINT16(m_LongestMatchDistance);
    m_OnePosMatchesArray[aGoodIndex].LongestMatchLength = UINT16(m_LongestMatchLength);
  }
  HRESULT aResult = m_MatchFinder.MovePos();
  if (aResult != S_OK)
    throw aResult;
  m_FinderPos++;
  m_AdditionalOffset++;
}
Subtitling::Subtitling(const uint8_t * const buffer)
{
	iso639LanguageCode.assign((char *)&buffer[0], 3);
	subtitlingType = buffer[3];
	compositionPageId = UINT16(&buffer[4]);
	ancillaryPageId = UINT16(&buffer[6]);
}
Example #3
0
File: vs_tag.c Project: verse/verse
/**
 * \brief This function tries to handle Tag_Destroy command
 */
int vs_handle_tag_destroy(struct VS_CTX *vs_ctx,
                          struct VSession *vsession,
                          struct Generic_Cmd *tag_destroy)
{
    struct VSNode			*node;
    struct VSTagGroup		*tg;
    struct VSTag			*tag;
    uint32 					node_id = UINT32(tag_destroy->data[0]);
    uint16 					taggroup_id = UINT16(tag_destroy->data[UINT32_SIZE]);
    uint16					tag_id = UINT16(tag_destroy->data[UINT32_SIZE + UINT16_SIZE]);
    int						ret = 0;

    /* Try to find node */
    if((node = vs_node_find(vs_ctx, node_id)) == NULL) {
        v_print_log(VRS_PRINT_DEBUG_MSG, "%s() node (id: %d) not found\n",
                    __FUNCTION__, node_id);
        return 0;
    }

    pthread_mutex_lock(&node->mutex);

    /* Node has to be created */
    if(vs_node_is_created(node) != 1) {
        goto end;
    }

    /* Is user owner of this node or can user write to this node? */
    if(vs_node_can_write(vsession, node) != 1) {
        v_print_log(VRS_PRINT_DEBUG_MSG,
                    "%s(): user: %s can't write to node: %d\n",
                    __FUNCTION__,
                    ((struct VSUser *)vsession->user)->username,
                    node->id);
        goto end;
    }

    /* Try to find TagGroup */
    if( (tg = vs_taggroup_find(node, taggroup_id)) == NULL) {
        v_print_log(VRS_PRINT_DEBUG_MSG,
                    "%s() tag_group (id: %d) in node (id: %d) not found\n",
                    __FUNCTION__, taggroup_id, node_id);
        goto end;
    }

    /* Try to find Tag */
    if ( (tag = vs_tag_find(tg, tag_id)) == NULL) {
        v_print_log(VRS_PRINT_DEBUG_MSG,
                    "%s() tag (id: %d) in tag_group (id: %d), node (id: %d) not found\n",
                    __FUNCTION__, tag_id, taggroup_id, node_id);
        goto end;
    }

    ret = vs_tag_send_destroy(node, tg, tag);

end:
    pthread_mutex_unlock(&node->mutex);

    return ret;
}
RunningStatus::RunningStatus(const uint8_t* const buffer)
{
	transportStreamId = UINT16(&buffer[0]);
	originalNetworkId = UINT16(&buffer[2]);
	serviceId = UINT16(&buffer[4]);
	eventId = UINT16(&buffer[6]);
	runningStatus = UINT16(&buffer[8]) & 0x03;
}
ServiceMoveDescriptor::ServiceMoveDescriptor(const uint8_t * const buffer) : Descriptor(buffer)
{
	ASSERT_MIN_DLEN(6);

	newOriginalNetworkId = UINT16(&buffer[2]);
	newTransportStreamId = UINT16(&buffer[4]);
	newServiceId = UINT16(&buffer[6]);
}
TransportStreamInfo::TransportStreamInfo(const uint8_t * const buffer)
{
	transportStreamId = UINT16(&buffer[0]);
	originalNetworkId = UINT16(&buffer[2]);
	transportDescriptorsLength = DVB_LENGTH(&buffer[4]);

	for (size_t i = 6; i < transportDescriptorsLength + 6; i += buffer[i + 1] + 2)
		descriptor(&buffer[i], SCOPE_SI);
}
Example #7
0
TimeAndDateSection::TimeAndDateSection(const uint8_t * const buffer) : ShortSection(buffer)
{
	if (sectionLength >= 5) {
		utcTimeMjd = UINT16(&buffer[3]);
		utcTimeBcd = (buffer[5] << 16) | UINT16(&buffer[6]);
	}
	else {
		utcTimeMjd=0;
		utcTimeBcd=0;
	}
}
Example #8
0
/**
 * \brief This function initialize values of structure
 */
static void _v_tag_destroy_init(struct Generic_Cmd *tag_destroy,
                                const uint32 node_id,
                                const uint16 taggroup_id,
                                const uint16 tag_id)
{
    if(tag_destroy != NULL) {

        tag_destroy->id = CMD_TAG_DESTROY;
        UINT32(tag_destroy->data[0]) = node_id;
        UINT16(tag_destroy->data[UINT32_SIZE]) = taggroup_id;
        UINT16(tag_destroy->data[UINT32_SIZE + UINT16_SIZE]) = tag_id;
    }
}
Example #9
0
int32_t cam_getFrameChirp(const uint8_t &type, const uint16_t &xOffset, const uint16_t &yOffset, const uint16_t &xWidth, const uint16_t &yWidth, Chirp *chirp)
{
	int32_t result, prebuf;
	uint8_t *frame = (uint8_t *)SRAM0_LOC;

	// force an error to get prebuf length
	CRP_RETURN(chirp, USE_BUFFER(SRAM0_SIZE, frame), HTYPE(0), UINT16(0), UINT16(0), UINTS8(0, 0), END);
	prebuf = chirp->getPreBufLen();

	if ((result=cam_getFrame(frame+prebuf, SRAM0_SIZE-prebuf, type, xOffset, yOffset, xWidth, yWidth))>=0)
		// send frame, use in-place buffer	
		CRP_RETURN(chirp, USE_BUFFER(SRAM0_SIZE, frame), HTYPE(FOURCC('B','A','8','1')), UINT16(xWidth), UINT16(yWidth), UINTS8(xWidth*yWidth, frame+prebuf), END);

	return result;
}
Example #10
0
void QFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags) const
{
    if (m_directWriteFontFace == 0)
        return;

    QVarLengthArray<UINT16> glyphIndices(glyphs->numGlyphs);

    // ### Caching?
    for(int i=0; i<glyphs->numGlyphs; i++)
        glyphIndices[i] = UINT16(glyphs->glyphs[i]);

    QVarLengthArray<DWRITE_GLYPH_METRICS> glyphMetrics(glyphIndices.size());
    HRESULT hr = m_directWriteFontFace->GetDesignGlyphMetrics(glyphIndices.data(),
                                                              glyphIndices.size(),
                                                              glyphMetrics.data());
    if (SUCCEEDED(hr)) {
        for (int i=0; i<glyphs->numGlyphs; ++i) {
            glyphs->advances_x[i] = DESIGN_TO_LOGICAL(glyphMetrics[i].advanceWidth);
            if (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
                glyphs->advances_x[i] = glyphs->advances_x[i].round();
            glyphs->advances_y[i] = 0;
        }
    } else {
        qErrnoWarning("QFontEngineDirectWrite::recalcAdvances: GetDesignGlyphMetrics failed");
    }
}
NetworkInformationSection::NetworkInformationSection(const uint8_t * const buffer) : LongCrcSection(buffer)
{
	networkId = UINT16(&buffer[3]);
	networkDescriptorsLength = sectionLength > 9 ? DVB_LENGTH(&buffer[8]) : 0;
	
	uint16_t pos = 10;
	uint16_t bytesLeft = sectionLength > 11 ? sectionLength - 11 : 0;
	uint16_t loopLength = 0;
	uint16_t bytesLeft2 = networkDescriptorsLength;

	while ( bytesLeft >= bytesLeft2 && bytesLeft2 > 1 && bytesLeft2 >= (loopLength = 2 + buffer[pos+1])) {
		descriptor(&buffer[pos], SCOPE_SI);
		pos += loopLength;
		bytesLeft -= loopLength;
		bytesLeft2 -= loopLength;
	}

	if (!bytesLeft2 && bytesLeft > 1) {
		bytesLeft2 = transportStreamLoopLength = DVB_LENGTH(&buffer[pos]);
		bytesLeft -= 2;
		pos += 2;
		while (bytesLeft >= bytesLeft2 && bytesLeft2 > 4 && bytesLeft2 >= (loopLength = 6 + DVB_LENGTH(&buffer[pos+4]))) {
			tsInfo.push_back(new TransportStreamInfo(&buffer[pos]));
			bytesLeft -= loopLength;
			bytesLeft2 -= loopLength;
			pos += loopLength;
		}
	}
}
Example #12
0
int vs_handle_layer_unsubscribe(struct VS_CTX *vs_ctx,
		struct VSession *vsession,
		struct Generic_Cmd *layer_unsubscribe_cmd)
{
	struct VSNode *node;
	struct VSLayer *layer;

	uint32 node_id = UINT32(layer_unsubscribe_cmd->data[0]);
	uint16 layer_id = UINT16(layer_unsubscribe_cmd->data[UINT32_SIZE]);
/*
	uint32 version = UINT32(layer_subscribe_cmd->data[UINT32_SIZE+UINT16_SIZE]);
	uint32 crc32 = UINT32(layer_subscribe_cmd->data[UINT32_SIZE+UINT16_SIZE+UINT32_SIZE]);
*/

	/* Try to find node */
	if((node = vs_node_find(vs_ctx, node_id)) == NULL) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s() node (id: %d) not found\n",
				__FUNCTION__, node_id);
		return 0;
	}

	/* Try to find layer */
	if( (layer = vs_layer_find(node, layer_id)) == NULL) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s() layer (id: %d) in node (id: %d) not found\n",
				__FUNCTION__, layer_id, node_id);
		return 0;
	}

	return vs_layer_unsubscribe(layer, vsession);
}
Example #13
0
void rcs_loadParams()
{
	prm_add("S0 lower limit", PRM_FLAG_SIGNED, 
		"@c Servo Sets the lower limit of travel for S0 (default -200)", INT16(-200), END);
	prm_add("S0 upper limit", PRM_FLAG_SIGNED, 
		"@c Servo Sets the upper limit of travel for S0 (default 200)", INT16(200), END);
	prm_add("S1 lower limit", PRM_FLAG_SIGNED, 
		"@c Servo Sets the lower limit of travel for S1 (default -200)", INT16(-200), END);
	prm_add("S1 upper limit", PRM_FLAG_SIGNED, 
		"@c Servo Sets the upper limit of travel for S1 (default 200)", INT16(200), END);
	prm_add("Servo frequency", PRM_FLAG_ADVANCED, 
		"@c Servo Sets the PWM frequency of the servos (default 100)", UINT16(100), END);

	int16_t lower, upper, freq;

	prm_get("S0 lower limit", &lower, END);
	prm_get("S0 upper limit", &upper, END);
	rcs_setLimits(0, lower, upper);

	prm_get("S1 lower limit", &lower, END);
	prm_get("S1 upper limit", &upper, END);
	rcs_setLimits(1, lower, upper);

	prm_get("Servo frequency", &freq, END);
	rcs_setFreq(freq);
}
Example #14
0
/**
 * \brief This function tries to handle node_create command
 */
int vs_handle_node_create(struct VS_CTX *vs_ctx,
		struct VSession *vsession,
		struct Generic_Cmd *node_create)
{
	uint16 user_id = UINT16(node_create->data[0]);
	uint32 parent_id = UINT32(node_create->data[UINT16_SIZE]);
	uint32 node_id = UINT32(node_create->data[UINT16_SIZE+UINT32_SIZE]);
	uint16 custom_type = UINT16(node_create->data[UINT16_SIZE+UINT32_SIZE+UINT32_SIZE]);

	/* Client has to send node_create command with node_id equal to
	 * the value 0xFFFFFFFF */
	if(node_id != VRS_RESERVED_NODE_ID) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s() node_id is 0xFFFFFFFF\n",
				__FUNCTION__);
		return 0;
	}

	/* Client has to send node_create with parent_id equal to its avatar_id */
	if(parent_id != vsession->avatar_id) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s() parent_id: %d is not equal to session avatar id %d\n",
				__FUNCTION__, parent_id, vsession->avatar_id);
		return 0;
	}

	/* Client has to send node_create command with his user_id */
	if(user_id != vsession->user_id) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s() user_id: %d is not equal to session user id %d\n",
				__FUNCTION__, user_id, vsession->user_id);
		return 0;
	}

	/* Client has to send node_create command with custom_type bigger or
	 * equal 32, because lower values are reserved for special nodes */
	if( custom_type < 32 ) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s() custom_type: %d is smaller then 32\n",
				__FUNCTION__, custom_type);
		return 0;
	}

	if(vs_node_new(vs_ctx, vsession, custom_type) != NULL) {
		return 1;
	} else {
		return 0;
	}

	return 0;
}
Example #15
0
int32_t cam_getFrame(uint8_t *memory, uint32_t memSize, uint8_t type, uint16_t xOffset, uint16_t yOffset, uint16_t xWidth, uint16_t yWidth)
{
	int32_t res;
	int32_t responseInt = -1;

	if (xWidth*yWidth>memSize)
		return -2;

	// check resolutions
	res = type >> 4;
	if (res==0)
	{
		if (xOffset+xWidth>CAM_RES0_WIDTH || yOffset+yWidth>CAM_RES0_HEIGHT)
			return -1;
	}
	else if (res==1) 
	{
		if (xOffset+xWidth>CAM_RES1_WIDTH || yOffset+yWidth>CAM_RES1_HEIGHT)
			return -1;
	}
	else if (res==2)
	{
		if (xOffset+xWidth>CAM_RES2_WIDTH || yOffset+yWidth>CAM_RES2_HEIGHT)
			return -1;
	}
	else
		return -3;

	// check mode, set if necessary
	if ((res=cam_setMode(type&0x0f))<0)
		return res;

	// forward call to M0, get frame
	g_chirpM0->callSync(g_getFrameM0, 
		UINT8(type), UINT32((uint32_t)memory), UINT16(xOffset), UINT16(yOffset), UINT16(xWidth), UINT16(yWidth), END_OUT_ARGS,
		&responseInt, END_IN_ARGS);

	if (responseInt==0)
	{
		g_rawFrame.m_pixels = memory;
		g_rawFrame.m_width = xWidth;
		g_rawFrame.m_height = yWidth;
	}

	return responseInt;
}
Example #16
0
int vs_handle_layer_destroy(struct VS_CTX *vs_ctx,
		struct VSession *vsession,
		struct Generic_Cmd *layer_destroy_cmd)
{
	struct VSNode *node;
	struct VSLayer *layer;
	struct VSUser *user;

	uint32 node_id = UINT32(layer_destroy_cmd->data[0]);
	uint16 layer_id = UINT16(layer_destroy_cmd->data[UINT32_SIZE]);

	/* Try to find node */
	if((node = vs_node_find(vs_ctx, node_id)) == NULL) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s() node (id: %d) not found\n",
				__FUNCTION__, node_id);
		return 0;
	}

	/* Node has to be created */
	if(!(node->state == ENTITY_CREATED || node->state == ENTITY_CREATING)) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s() node (id: %d) is not in CREATING or CREATED state: %d\n",
				__FUNCTION__, node->id, node->state);
		return 0;
	}

	/* Try to find user */
	if((user = vs_user_find(vs_ctx, vsession->user_id)) == NULL) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s() vsession->user_id: %d not found\n",
				__FUNCTION__, vsession->user_id);
		return 0;
	}

	/* User has to have permission to write to the node */
	if(vs_node_can_write(vs_ctx, vsession, node) != 1) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s(): user: %s can't write to node: %d\n",
				__FUNCTION__, user->username, node->id);
		return 0;
	}

	/* Try to find layer */
	if( (layer = vs_layer_find(node, layer_id)) == NULL) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s() layer (id: %d) in node (id: %d) not found\n",
				__FUNCTION__, layer_id, node_id);
		return 0;
	}

	/* Layer has to be created */
	if(! (layer->state == ENTITY_CREATING || layer->state == ENTITY_CREATED)) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s() layer (id: %u) in node (id: %d) is not in CREATED state: %d\n",
				__FUNCTION__, layer->id, node->id, node->state);
		return 0;
	}

	layer->state = ENTITY_DELETING;

	return vs_layer_send_destroy(node, layer);
}
Example #17
0
int32_t cc_getRLSFrameChirp(Chirp *chirp)
{
	int32_t result;
	uint32_t len, numRls;

	// figure out prebuf length (we need the prebuf length and the number of runlength segments, but there's a chicken and egg problem...)
	len = Chirp::serialize(chirp, RLS_MEMORY, RLS_MEMORY_SIZE,  HTYPE(0), UINT16(0), UINT16(0), UINTS32_NO_COPY(0), END);

	result = cc_getRLSFrame((uint32_t *)(RLS_MEMORY+len), LUT_MEMORY, &numRls);
	// send frame, use in-place buffer
	Chirp::serialize(chirp, RLS_MEMORY, RLS_MEMORY_SIZE,  HTYPE(FOURCC('C','C','Q','1')), UINT16(CAM_RES2_WIDTH), UINT16(CAM_RES2_HEIGHT), UINTS32_NO_COPY(numRls), END);
	// copy from IPC memory to RLS_MEMORY
	if (g_qqueue->readAll((Qval *)(RLS_MEMORY+len), (RLS_MEMORY_SIZE-len)/sizeof(Qval))!=numRls)
		return -1;
	chirp->useBuffer(RLS_MEMORY, len+numRls*4);

	return result;
}
Example #18
0
File: i8x9x.c Project: opicron/mame
UINT64 i8x9x_device::timer_time_until(int timer, UINT64 current_time, UINT16 timer_value) const
{
	UINT64 timer_base = timer == 2 ? base_timer2 : 0;
	UINT64 delta = (current_time - timer_base) >> 3;
	UINT32 tdelta = UINT16(timer_value - delta);
	if(!tdelta)
		tdelta = 0x10000;
	return timer_base + ((delta + tdelta) << 3);
}
CaDescriptor::CaDescriptor(const uint8_t * const buffer) : Descriptor(buffer)
{
    ASSERT_MIN_DLEN(4);

    caSystemId = UINT16(&buffer[2]);
    caPid = DVB_PID(&buffer[4]);

    caDataBytes.resize(descriptorLength - 4);
    memcpy(&caDataBytes[0], &buffer[6], descriptorLength - 4);
}
Example #20
0
static exe_handle_t *
lzexe_open(const char *filename)
{
	exe_handle_t *handle;
	guint8 head[0x20];
	guint8 size[2];
	off_t fpos;

	FILE *f = sci_fopen(filename, "rb");

	if (!f)
		return NULL;

	/* Read exe header plus possible lzexe signature. */
	if (fread(head, 1, 0x20, f) != 0x20)
		return NULL;

	/* Verify "MZ" signature, header size == 2 paragraphs and number of
	** overlays == 0.
	*/
	if (UINT16(head) != 0x5a4d || UINT16(head + 8) != 2
	    || UINT16(head + 0x1a) != 0)
		return NULL;

	/* Verify that first relocation item offset is 0x1c. */
	if (UINT16(head + 0x18) != 0x1c)
		return NULL;

	/* Look for lzexe signature. */
	if (memcmp(head + 0x1c, "LZ09", 4)
            && memcmp(head + 0x1c, "LZ91", 4)) {
		return NULL;
	}

	/* Calculate code segment offset in exe file. */
	fpos = (UINT16(head + 0x16) + UINT16(head + 8)) << 4;
	/* Seek to offset 8 of info table at start of code segment. */
	if (fseek(f, fpos + 8, SEEK_SET) == -1)
		return NULL;

	/* Read size of compressed data in paragraphs. */
	if (fread(size, 1, 2, f) != 2)
		return NULL;

	/* Move file pointer to start of compressed data. */
	fpos -= UINT16(size) << 4;
	if (fseek(f, fpos, SEEK_SET) == -1)
		return NULL;

	handle = (exe_handle_t*)sci_malloc(sizeof(exe_handle_t));

	if (!lzexe_init(handle, f)) {
		sci_free(handle);
		return NULL;
	}

	return handle;
}
Example #21
0
CpDescriptor::CpDescriptor(const uint8_t * const buffer) : Descriptor(buffer)
{
	ASSERT_MIN_DLEN(5);

	cpSystemId = UINT16(&buffer[3]);
	cpPid = DVB_PID(&buffer[5]);

	cpDataBytes.resize(descriptorLength - 5);
	memcpy(&cpDataBytes[0], &buffer[7], descriptorLength - 5);
}
void cc_loadParams(void)
{
	int i;
	ColorModel model;
	char id[32], desc[32];

	// set up signatures, load later
	for (i=1; i<=NUM_MODELS; i++)
	{
		sprintf(id, "signature%d", i);
		sprintf(desc, "Color signature %d", i);
		// add if it doesn't exist yet
		prm_add(id, PRM_FLAG_INTERNAL, desc, INTS8(sizeof(ColorModel), &model), END);
	}

	// others -----

	// setup
	prm_add("Max blocks", 0, 
		"Sets the maximum total blocks sent per frame. (default 1000)", UINT16(1000), END);
	prm_add("Max blocks per signature", 0, 
		"Sets the maximum blocks for each color signature sent for each frame. (default 1000)", UINT16(1000), END);
	prm_add("Min block area", 0, 
	"Sets the minimum required area in pixels for a block.  Blocks with less area won't be sent. (default 20)", UINT32(1), END); //TMS: default 20
	prm_add("Min saturation", 0,
		"@c Signature_creation Sets the minimum allowed color saturation for when generating color signatures. Applies during teaching. (default 15.0)", FLT32(15.0), END);
	prm_add("Hue spread", 0,
		"@c Signature_creation Sets how inclusive the color signatures are with respect to hue. Applies during teaching. (default 1.5)", FLT32(1.5), END);
	prm_add("Saturation spread", 0,
		"@c Signature_creation Sets how inclusive the color signatures are with respect to saturation. Applies during teaching. (default 1.5)", FLT32(1.5), END);
	prm_add("CC min saturation", 0,
		"@c Signature_creation Sets the minimum allowed color saturation for when generating color code (CC) signatures. Applies during teaching. (default 15.0)", FLT32(15.0), END);
	prm_add("CC hue spread", 0,
		"@c Signature_creation Sets how inclusive the color code (CC) signatures are with respect to hue. Applies during teaching. (default 3.0)", FLT32(3.0), END);
	prm_add("CC saturation spread", 0,
		"@c Signature_creation Sets how inclusive the color code (CC) signatures are with respect to saturation for color codes. Applies during teaching. (default 50.0)", FLT32(50.0), END);
	prm_add("Color code mode", 0,
		"Sets the color code mode, 0=disabled, 1=enabled, 2=color codes only, 3=mixed (default 1)", INT8(1), END);

	// load
	uint8_t ccMode;
	uint16_t maxBlobs, maxBlobsPerModel;
	uint32_t minArea;

	prm_get("Max blocks", &maxBlobs, END);
	prm_get("Max blocks per signature", &maxBlobsPerModel, END);
	prm_get("Min block area", &minArea, END);
	prm_get("Color code mode", &ccMode, END);
	g_blobs->setParams(maxBlobs, maxBlobsPerModel, minArea, (ColorCodeMode)ccMode);

	cc_loadLut();

}
Example #23
0
UINT16 CHXAudioDevice::GetVolume()
{
    UINT16 vol = 0;
    if (m_pAudioStream)
    {
        vol = UINT16(Scale(UINT32(m_pAudioStream->GetVolume()),
                           m_uMinDevVolume, m_uMaxDevVolume,
                           m_uMinPlayerVolume, m_uMaxPlayerVolume));
    }

    return vol;
}
Example #24
0
// 是否有魂
CSoul* CPlayerSoul::GetSoul(UINT16 usSoulId, UINT32 unIndex) {
	if (0 == usSoulId) {
		return NULL;
	}

	UINT64 ullKey = CLogicFunc::Get3216Key(UINT32(usSoulId), UINT16(unIndex));
	CMapSoulItr itor = m_mpSoulData.find(ullKey);
	if (m_mpSoulData.end() != itor) {
		return &itor->second;
	}

	return NULL;
}
Example #25
0
/**
 * \brief This function initialize structure of TagGroup_Subscribe command
 */
static void _v_taggroup_unsubscribe_init(struct Generic_Cmd *taggroup_unsubscribe,
        uint32 node_id,
        uint16 taggroup_id,
        uint32 version,
        uint32 crc32)
{
    if(taggroup_unsubscribe != NULL) {
        taggroup_unsubscribe->id = CMD_TAGGROUP_UNSUBSCRIBE;
        UINT32(taggroup_unsubscribe->data[0]) = node_id;
        UINT16(taggroup_unsubscribe->data[UINT32_SIZE]) = taggroup_id;
        UINT32(taggroup_unsubscribe->data[UINT32_SIZE+UINT16_SIZE]) = version;
        UINT32(taggroup_unsubscribe->data[UINT32_SIZE+UINT16_SIZE+UINT32_SIZE]) = crc32;
    }
}
Example #26
0
int CFITOM::GetVoice(FMVOICE* voice, UINT8 dev, UINT8 bank, UINT8 prog)
{
	CVoiceBank* xmem = NULL;
	UINT8 vtype = GetVoiceType(dev);
	if (bank < MAX_BANK && prog < 128 && (xmem = GetVoiceMem(vtype, bank))) {
		xmem->GetVoice(prog, voice);
	}
	if (xmem == NULL) {
		memset(voice, 0, sizeof(FMVOICE));
		voice->ID = (0xff000000L) | (UINT16(bank) << 8) | prog;
		wsprintf(voice->name, _T("%03i:%03i"), bank, prog);
	}
	return 0;
}
Example #27
0
/**
 * \brief This function handle command layer_unset_value
 */
int vs_handle_layer_unset_value(struct VS_CTX *vs_ctx,
		struct VSession *vsession,
		struct Generic_Cmd *layer_unset_value_cmd)
{
	struct VSNode *node;
	struct VSLayer *layer;
	struct VSUser *user;

	uint32 node_id = UINT32(layer_unset_value_cmd->data[0]);
	uint16 layer_id = UINT16(layer_unset_value_cmd->data[UINT32_SIZE]);
	uint32 item_id = UINT32(layer_unset_value_cmd->data[UINT32_SIZE + UINT16_SIZE]);

	/* Try to find node */
	if((node = vs_node_find(vs_ctx, node_id)) == NULL) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s() node (id: %d) not found\n",
				__FUNCTION__, node_id);
		return 0;
	}

	/* Try to find user */
	if((user = vs_user_find(vs_ctx, vsession->user_id)) == NULL) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s() vsession->user_id: %d not found\n",
				__FUNCTION__, vsession->user_id);
		return 0;
	}

	/* User has to have permission to write to the node */
	if(vs_node_can_write(vs_ctx, vsession, node) != 1) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s(): user: %s can't write to the node: %d\n",
				__FUNCTION__, user->username, node->id);
		return 0;
	}

	/* Try to find layer */
	if( (layer = vs_layer_find(node, layer_id)) == NULL) {
		v_print_log(VRS_PRINT_DEBUG_MSG, "%s() layer (id: %d) in node (id: %d) not found\n",
				__FUNCTION__, layer_id, node_id);
		return 0;
	}

	return vs_layer_unset_value(node, layer, item_id, 1);
}
Example #28
0
int Interpreter::sendGetAction(int index)
{
    int res, response;
    char *action, *scriptlet;
    QStringList scriptlet2;
    QString action2;

    res = m_chirp->callSync(m_exec_get_action, UINT16(index), END_OUT_ARGS, &response, &action, &scriptlet, END_IN_ARGS);

    if (res<0)
        return res;

    if (response<0)
        return response;

    action2 = QString(action);
    scriptlet2 = QString(scriptlet).split(QRegExp("[\\n]"), QString::SkipEmptyParts);

    emit actionScriptlet(index, action2, scriptlet2);
    return response;
}
int Interpreter::sendGetAction(int index)
{
    int res, response;
    char *action, *scriptlet;
    QStringList scriptlet2;
    QString action2;

    res = m_chirp->callSync(m_exec_get_action, UINT16(index), END_OUT_ARGS, &response, &action, &scriptlet, END_IN_ARGS);

    if (res<0)
        return res;

    if (response<0)
        return response;

    action2 = QString(action);
    scriptlet2 = parseScriptlet(scriptlet);

    emit actionScriptlet(action2, scriptlet2);
    return response;
}
Example #30
0
BOOL CPlayerSoul::DelSoulFromBag(CSoul* pSoul) {
	if (NULL == pSoul) {
		return FALSE;
	}

	if (0 >= m_stSoulData.stSoulBagData.wSoulNum) {
		PRINT_ERR_INFO;
		return FALSE;
	}

	DT_SOUL_DATA& rSoulData = pSoul->GetDT_SOUL_DATA();
	for (size_t n = 0; n < MAX_SOUL_BAG_NUM; ++n) {
		if (m_stSoulData.stSoulBagData.astSoulLstData[n].wSoulID == rSoulData.wSoulID
			&& m_stSoulData.stSoulBagData.astSoulLstData[n].dwSoulIdx == rSoulData.dwSoulIdx)
		{
			for (size_t nIdx = n; nIdx < MAX_SOUL_BAG_NUM; ++nIdx) {
				if (nIdx != (MAX_SOUL_BAG_NUM - 1)) {
					memcpy(&m_stSoulData.stSoulBagData.astSoulLstData[nIdx], &m_stSoulData.stSoulBagData.astSoulLstData[nIdx + 1], sizeof(DT_SOUL_DATA));
					memcpy(&m_stSoulData.stSoulPotencyBagData.astSoulPotencyLstData[nIdx], &m_stSoulData.stSoulPotencyBagData.astSoulPotencyLstData[nIdx + 1], sizeof(DT_SOUL_POTENCY_DATA));
				} else {
					memset(&m_stSoulData.stSoulBagData.astSoulLstData[nIdx], 0, sizeof(DT_SOUL_DATA));
					memset(&m_stSoulData.stSoulPotencyBagData.astSoulPotencyLstData[nIdx], 0, sizeof(DT_SOUL_POTENCY_DATA));
				}
			}
			
			-- m_stSoulData.stSoulBagData.wSoulNum;
			m_stSoulData.stSoulPotencyBagData.wSoulNum = m_stSoulData.stSoulBagData.wSoulNum;
			UINT64 ullKey = CLogicFunc::Get3216Key(UINT32(rSoulData.wSoulID), UINT16(rSoulData.dwSoulIdx));
			CMapSoulItr itor = m_mpSoulData.find(ullKey);
			if (m_mpSoulData.end() != itor) {
				m_mpSoulData.erase(itor);
			}
			return TRUE;
		}
	}
	return FALSE;
}