bool videoInputCamera::setSizeAndSubtype() {

	//store current mediatype
	AM_MEDIA_TYPE * tmpType = NULL;
	HRESULT	hr = pStreamConfig->GetFormat(&tmpType);
	if(hr != S_OK)return false;

	VIDEOINFOHEADER *lpVih =  reinterpret_cast<VIDEOINFOHEADER*>(pAmMediaType->pbFormat);
	HEADER(lpVih)->biWidth  = cfg->cam_width;
	HEADER(lpVih)->biHeight = cfg->cam_height;

	pAmMediaType->formattype = FORMAT_VideoInfo;
	pAmMediaType->majortype  = MEDIATYPE_Video;
	pAmMediaType->subtype	 = getMediaSubtype(cfg->cam_format);

	//buffer size
	pAmMediaType->lSampleSize = cfg->cam_width* cfg->cam_height*3;

	//set fps if requested
	lpVih->AvgTimePerFrame = (unsigned long)(10000000 /  cfg->cam_fps);

	//okay lets try new size
	hr = pStreamConfig->SetFormat(pAmMediaType);
	if(hr == S_OK){
		if( tmpType != NULL )deleteMediaType(tmpType);
		return true;
	}else{
		pStreamConfig->SetFormat(tmpType);
		if( tmpType != NULL )deleteMediaType(tmpType);
	}

	return false;
}
/* sort the IDE block as per the typelib spec: IID order, unresolved first */
static void
sort_ide_block(TreeState *state)
{
    XPTInterfaceDirectoryEntry *ide;
    int i;

    /* boy, I sure hope qsort works correctly everywhere */
#ifdef DEBUG_shaver_sort
    fputs("before sort:\n", stderr);
    for (i = 0; i < IFACES(state); i++) {
        fputs("  ", stderr);
        print_IID(&HEADER(state)->interface_directory[i].iid, stderr);
        fputc('\n', stderr);
    }
#endif
    qsort(HEADER(state)->interface_directory, IFACES(state),
          sizeof(*ide), compare_IDEs);
#ifdef DEBUG_shaver_sort
    fputs("after sort:\n", stderr);
    for (i = 0; i < IFACES(state); i++) {
        fputs("  ", stderr);
        print_IID(&HEADER(state)->interface_directory[i].iid, stderr);
        fputc('\n', stderr);
    }
#endif

    for (i = 0; i < IFACES(state); i++) {
        ide = HEADER(state)->interface_directory + i;
        g_hash_table_insert(IFACE_MAP(state), ide->name, (void *)(i + 1));
    }

    return;
}
Beispiel #3
0
rt_public EIF_BOOLEAN eequal(register EIF_REFERENCE target, register EIF_REFERENCE source)
{
	/* Eiffel standard equality: it assumes that dynamic type of Eiffel
	 * object refered by `source' conforms to dynamic type of Eiffel
	 * object refered by `target'. `source' and `target' cannot be NULL
	 * or special objects here.
	 * If both `source' and `target' have the same dynamic type and this
	 * type is not composite, then perform a block comparison; otherwise
	 * perform a field by field comparison.
	 * It is the feature `standard_is_equal' of class ANY.
	 * Return a boolean.
	 */

	REQUIRE ("source_not_null", source);
	REQUIRE ("target_not_null", target);

	if (source == target) {
			/* Minor optimization, if references are equal then it is the same object. */
		return EIF_TRUE;
	}

	if (Dftype(source) == Dftype(target)) {
		/* Dynamic type are the same: because of the intra-expanded
		 * references, we can perform only a block comparison if
		 * the target (or the source) is a composite object (i.e: it has
		 * expanded attributes): since an attribute keeps expanded or
		 * not expanded all the time, we can test either the source or
		 * the target.
		 */
		if (HEADER(source)->ov_flags & EO_SPEC) {
				/* Works for both SPECIAL and TUPLE object */
				/* Eiffel standard equality on special objects: type check assumes
				* the comparison is on areas of the same type (containing the same
				* thing). Called by the redefinition of feature `equal' of special
				* class. `source' and/or `target' cannot be NULL.
				* Return a boolean.
				*/

				/* First condition: same count */
			if
				((RT_SPECIAL_COUNT(source) != RT_SPECIAL_COUNT(target)) ||
				(RT_SPECIAL_ELEM_SIZE(source) != RT_SPECIAL_ELEM_SIZE(target)))
			{
				return EIF_FALSE;
			} else {
					/* Second condition: block equality */
				return EIF_TEST(!memcmp (source, target, RT_SPECIAL_VISIBLE_SIZE(source)));
			}
		} else {
			if (!(HEADER(source)->ov_flags & EO_COMP))	/* Perform a block comparison */
				return EIF_TEST(!memcmp (source, target, EIF_Size(Dtype(source))));
			else
				return e_field_equal(target, source);
		}
	}

	/* Field by field comparison */

	return EIF_FALSE;
}
Beispiel #4
0
gboolean http_request_ok (http_request *h) {
    guint hdr_len = http_get_hdr_len( h->buffer->str );
    guint c_len;

    if (hdr_len != 0) {
	if(CONFd("Verbosity") >= 8) g_warning( "http_request_ok: hdr_len %d", hdr_len );

	if ( HEADER("Content-length") && (c_len=atoi(HEADER("Content-length")) <= (h->buffer->len - hdr_len)) ) {
	    if(CONFd("Verbosity") >= 8) g_warning( "http_request_ok: Parsing query from HTTP-Content." );
	    http_parse_query( h, &(h->buffer->str[hdr_len]) );
	    h->complete++;
	    if(CONFd("Verbosity") >= 8) g_warning( "http_request_ok: Query parsing finished, exiting." );
	    return TRUE;
	}
	else if (HEADER("Content-length") && (CONFd("Verbosity") >= 8)) 
            g_warning( "http_request_ok: HEADER was OK, but CONTENT reading failed." );
	else if(CONFd("Verbosity") >= 8) 
            g_warning( "http_request_ok: No Content-length header, parsing query from URI." );
	http_parse_query( h, NULL );
	if (!h->query) {
          if (CONFd("Verbosity") >= 8) g_message("http_request_ok: No QUERY found.");
        }
	else if (CONFd("Verbosity") >= 8) {
	    GString *z;
            z = g_hash_as_string( h->query );
            g_debug( "http_request_ok: Query: %s", z->str );
            g_string_free(z, 1);
        }
	h->complete++;
	if(CONFd("Verbosity") >= 8) g_warning( "http_request_ok: Query parsing finished, exiting." );
	return TRUE;
    }
    if(CONFd("Verbosity") >= 6) g_warning( "http_request_ok: Request not HTTP: <CR><LF><CR><LF> (header_end) NOT found" );
    return FALSE;
}
Beispiel #5
0
rt_public void eif_std_ref_copy(register EIF_REFERENCE source, register EIF_REFERENCE target)
{
    /* Copy Eiffel object `source' into Eiffel object `target'.
     * Dynamic type of `source' is supposed to be the same as dynamic type
     * of `target'. It assumes also that `source' and `target' are not
     * references on special objects.
     * Problem: updating intra-references on expanded object
     * because the garbage collector needs to explore those references.
     */

    uint16 flags;			/* Source object flags */
    union overhead *s_zone;	/* Source object header */
    union overhead *t_zone;	/* Target object header */
#ifdef ISE_GC
    EIF_REFERENCE enclosing;					/* Enclosing target object */
#endif
    rt_uint_ptr size;

    s_zone = HEADER(source);
    flags = s_zone->ov_flags;
    t_zone = HEADER(target);

    if (s_zone->ov_dftype == t_zone->ov_dftype) {

        if (flags & EO_COMP) {
            /* Case of composite object: updating of references on expanded objects. */
            eif_std_field_copy (source, target);
        } else {
            /* Copy of source object into target object with same dynamic type. Block copy here. */
            if (flags & EO_SPEC) {
                size = RT_SPECIAL_VISIBLE_SIZE(source);
            } else {
                size = EIF_Size(s_zone->ov_dtype);
            }
            memmove(target, source, size);
        }

#ifdef ISE_GC
        /* Precompute the enclosing target object */
        enclosing = target;					/* By default */
        if (eif_is_nested_expanded(t_zone->ov_flags)) {
            enclosing -= t_zone->ov_size & B_SIZE;
        }

        /* Perform aging tests. We need the address of the enclosing object to
         * update the flags there, in case the target is to be memorized.
         */
        flags = HEADER(enclosing)->ov_flags;
        CHECK ("Not forwarded", !(HEADER (enclosing)->ov_size & B_FWD));

        if (
            flags & EO_OLD &&			/* Object is old */
            !(flags & EO_REM)	&&		/* Not remembered */
            refers_new_object(target)	/* And copied refers to new objects */
        )
            erembq(enclosing);			/* Then remember the enclosing object */
#endif /* ISE_GC */
    }
}
Beispiel #6
0
void cm_TRC_traceLoadMap(
        t_nmfTraceComponentCommandDescription command,
        const t_component_instance* component)
{
    if(cm_trace_enabled)
    {
        struct t_nmfTraceComponent   trace;

        /*
         * Generate instantiate trace
         */
        trace.header.v = HEADER(TRACE_TYPE_COMPONENT, sizeof(trace));

        trace.command = (t_uint16)command;
        trace.domainId = (t_uint16)component->Template->dspId + 1;
        trace.componentContext = (t_uint32)component->thisAddress;
        trace.componentUserContext = (t_uint32)component;
        cm_StringCopy((char*)trace.componentLocalName, component->pathname, MAX_COMPONENT_NAME_LENGTH);
        cm_StringCopy((char*)trace.componentTemplateName, component->Template->name, MAX_TEMPLATE_NAME_LENGTH);

        writeN((struct t_nmfTraceChannelHeader*)&trace);

        if(command == TRACE_COMPONENT_COMMAND_ADD)
        {
            struct t_nmfTraceMethod tracemethod;
            int i, j, k;

            /*
             * Generate method trace
             */
            tracemethod.header.v = HEADER(TRACE_TYPE_METHOD, sizeof(tracemethod));

            tracemethod.domainId = (t_uint16)component->Template->dspId + 1;
            tracemethod.componentContext = (t_uint32)component->thisAddress;

            for(i = 0; i < component->Template->provideNumber; i++)
            {
                t_interface_provide* provide = &component->Template->provides[i];
                t_interface_provide_loaded* provideLoaded = &component->Template->providesLoaded[i];

                for(j = 0; j < provide->collectionSize; j++)
                {
                    for(k = 0; k < provide->interface->methodNumber; k++)
                    {
                        tracemethod.methodId = provideLoaded->indexesLoaded[j][k].methodAddresses;

                        cm_StringCopy((char*)tracemethod.methodName, provide->interface->methodNames[k], MAX_INTERFACE_METHOD_NAME_LENGTH);

                        writeN((struct t_nmfTraceChannelHeader*)&tracemethod);
                    }
                }
            }
        }
    }
}
Beispiel #7
0
rt_private void spcopy(register EIF_REFERENCE source, register EIF_REFERENCE target)
{
    /* Copy a special Eiffel object into another one. It assumes that
     * `source' and `target' are not NULL and that count of `target' is greater
     * than count of `source'.
     */

    rt_uint_ptr field_size;
    rt_uint_ptr t_count, s_count;
#ifdef ISE_GC
    uint16 flags;
#endif

    REQUIRE ("source not null", source);
    REQUIRE ("target not null", target);
    REQUIRE ("source is special", HEADER(source)->ov_flags & EO_SPEC);
    REQUIRE ("target is special", HEADER(target)->ov_flags & EO_SPEC);
    REQUIRE ("target_elem_size_identical", RT_SPECIAL_ELEM_SIZE(target) == RT_SPECIAL_ELEM_SIZE(source));

    /* Because we can call copy with special/tuples of different size, we have to take the min size
     * of the two objects to know exactly how much we are allowed to copy without causing a
     * memory corruption. In case users actually call `copy' directly, not indirectly via `twin',
     * the postcondition of `copy' will be violated, although it would have been better to have
     * a precondition it is much better than memory corruption.*/

    /* FIXME: Once `copy' is not exported anymore to ANY, but just TUPLE/SPECIAL then we will be able
     * to add RT_SPECIAL_COUNT(target) == RT_SPECIAL_COUNT(source) as precondition of `spcopy'.*/

    t_count = RT_SPECIAL_COUNT(target);
    s_count = RT_SPECIAL_COUNT(source);
    field_size = (t_count > s_count ? s_count : t_count) * (rt_uint_ptr) RT_SPECIAL_ELEM_SIZE (source);
    memmove(target, source, field_size);			/* Block copy */

#ifdef ISE_GC
    /* Ok, normally we would have to perform age tests, by scanning the special
     * object, looking for new objects. But a special object can be really big,
     * and can also contain some expanded objects, which should be traversed
     * to see if they contain any new objects. Ok, that's enough! This is a
     * GC problem and is normally performed by the GC. So, if the special object
     * is old and contains some references, I am automatically inserting it
     * in the remembered set. The GC will remove it from there at the next
     * cycle, if necessary--RAM.
     */

    flags = HEADER(target)->ov_flags;
    CHECK ("Not forwarded", !(HEADER (target)->ov_flags & B_FWD));
    if ((flags & (EO_REF | EO_OLD | EO_REM)) == (EO_OLD | EO_REF))
        /* May it hold new references? */
        eremb(target);	/* Remember it, even if not needed, to fasten
								copying process. */
#endif /* ISE_GC */
}
Beispiel #8
0
static void lynx_image_info(imgtool_image *img, char *string, const int len)
{
	lynx_image *image=(lynx_image*)img;
	char dostext_with_null[33]= { 0 };
	char name_with_null[25]={ 0 };
	strncpy(dostext_with_null, HEADER(image)->dostext, 32);
	strncpy(name_with_null, HEADER(image)->description, 24);
	sprintf(string,"%s\n%s\nversion:%.4x max entries:%d",
			dostext_with_null,
			name_with_null, 
			GET_UWORD(HEADER(image)->version),
			HEADER(image)->max_entries);
}
Beispiel #9
0
/**
 * Initializes a DChat V1 structure containing all available and
 * supported headers of the DChat V1 protocol.
 * The given structure will be initialized with all headers
 * available. The header IDs and names will be set and function addresses
 * pointing to corresponding value parsers will be set too.
 * @param proto
 * @return 0 if structure has been initialized successfully, -1 otherwise
 */
int
init_dchat_v1(dchat_v1_t* proto)
{
    int temp_size;
    int proto_size;
    // available headers
    dchat_header_t temp[] =
    {
        HEADER(HDR_ID_VER, HDR_NAME_VER, 1, ver_str_to_pdu, ver_pdu_to_str),
        HEADER(HDR_ID_CTT, HDR_NAME_CTT, 1, ctt_str_to_pdu, ctt_pdu_to_str),
        HEADER(HDR_ID_CTL, HDR_NAME_CTL, 1, ctl_str_to_pdu, ctl_pdu_to_str),
        HEADER(HDR_ID_ONI, HDR_NAME_ONI, 1, oni_str_to_pdu, oni_pdu_to_str),
        HEADER(HDR_ID_LNP, HDR_NAME_LNP, 1, lnp_str_to_pdu, lnp_pdu_to_str),
        HEADER(HDR_ID_NIC, HDR_NAME_NIC, 0, nic_str_to_pdu, nic_pdu_to_str),
        HEADER(HDR_ID_DAT, HDR_NAME_DAT, 0, dat_str_to_pdu, dat_pdu_to_str),
        HEADER(HDR_ID_SRV, HDR_NAME_SRV, 0, srv_str_to_pdu, srv_pdu_to_str)
    };
    temp_size = sizeof(temp) / sizeof(temp[0]);

    if (temp_size > HDR_AMOUNT)
    {
        return -1;
    }

    memset(proto, 0, sizeof(*proto));
    memcpy(proto->header, &temp, sizeof(temp));
    return 0;
}
static gboolean
typelib_prolog(TreeState *state)
{
    state->priv = calloc(1, sizeof(struct priv_data));
    if (!state->priv)
        return FALSE;
    IFACES(state) = 0;
    IFACE_MAP(state) = g_hash_table_new(g_str_hash, g_str_equal);
    if (!IFACE_MAP(state)) {
        /* XXX report error */
        free(state->priv);
        return FALSE;
    }
    /* find all interfaces, top-level and referenced by others */
    IDL_tree_walk_in_order(state->tree, find_interfaces, state);
    ARENA(state) = XPT_NewArena(1024, sizeof(double), "main xpidl arena");
    HEADER(state) = XPT_NewHeader(ARENA(state), IFACES(state), 
                                  major_version, minor_version);

    /* fill IDEs from hash table */
    IFACES(state) = 0;
    g_hash_table_foreach_remove(IFACE_MAP(state), fill_ide_table, state);

    /* if any are left then we must have failed in fill_ide_table */
    if (g_hash_table_size(IFACE_MAP(state)))
        return FALSE;

    /* sort the IDEs by IID order and store indices in the interface map */
    sort_ide_block(state);

    return TRUE;
}
static int FUNC(extension_data)(CodedBitstreamContext *ctx, RWContext *rw,
                                MPEG2RawExtensionData *current)
{
    int err;

    HEADER("Extension Data");

    ui(8, extension_start_code);
    ui(4, extension_start_code_identifier);

    switch (current->extension_start_code_identifier) {
    case 1:
        return FUNC(sequence_extension)
            (ctx, rw, &current->data.sequence);
    case 2:
        return FUNC(sequence_display_extension)
            (ctx, rw, &current->data.sequence_display);
    case 3:
        return FUNC(quant_matrix_extension)
            (ctx, rw, &current->data.quant_matrix);
    case 7:
        return FUNC(picture_display_extension)
            (ctx, rw, &current->data.picture_display);
    case 8:
        return FUNC(picture_coding_extension)
            (ctx, rw, &current->data.picture_coding);
    default:
        av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid extension ID %d.\n",
               current->extension_start_code_identifier);
        return AVERROR_INVALIDDATA;
    }
}
static int FUNC(quant_matrix_extension)(CodedBitstreamContext *ctx, RWContext *rw,
                                        MPEG2RawQuantMatrixExtension *current)
{
    int err, i;

    HEADER("Quant Matrix Extension");

    ui(1, load_intra_quantiser_matrix);
    if (current->load_intra_quantiser_matrix) {
        for (i = 0; i < 64; i++)
            uis(8, intra_quantiser_matrix[i], 1, i);
    }

    ui(1, load_non_intra_quantiser_matrix);
    if (current->load_non_intra_quantiser_matrix) {
        for (i = 0; i < 64; i++)
            uis(8, non_intra_quantiser_matrix[i], 1, i);
    }

    ui(1, load_chroma_intra_quantiser_matrix);
    if (current->load_chroma_intra_quantiser_matrix) {
        for (i = 0; i < 64; i++)
            uis(8, intra_quantiser_matrix[i], 1, i);
    }

    ui(1, load_chroma_non_intra_quantiser_matrix);
    if (current->load_chroma_non_intra_quantiser_matrix) {
        for (i = 0; i < 64; i++)
            uis(8, chroma_non_intra_quantiser_matrix[i], 1, i);
    }

    return 0;
}
Beispiel #13
0
Datei: mm.c Projekt: js6450/CSO
static void deletefree(void *currblock) {
  int listcounter = 0;
  size_t size = GETSIZE(HEADER(currblock));
  
  for (;(listcounter < LISTS - 1) && (size > 1); listcounter++) {
    size >>= 1;
  }
  
  if (PREVFREE(currblock) != NULL) {
    if (NEXTFREE(currblock) != NULL) {
      SETPTR(NEXTPTR(PREVFREE(currblock)), NEXTFREE(currblock));
      SETPTR(PREVPTR(NEXTFREE(currblock)), PREVFREE(currblock));
    } else {
      SETPTR(NEXTPTR(PREVFREE(currblock)), NULL);
      free_lists[listcounter] = PREVFREE(currblock);
    }
  } else {
    if (NEXTFREE(currblock) != NULL) {
      SETPTR(PREVPTR(NEXTFREE(currblock)), NULL);
    } else {
      free_lists[listcounter] = NULL;
    }
  }
  
  return;
}
static int FUNC(user_data)(CodedBitstreamContext *ctx, RWContext *rw,
                           MPEG2RawUserData *current)
{
    size_t k;
    int err;

    HEADER("User Data");

    ui(8, user_data_start_code);

#ifdef READ
    k = get_bits_left(rw);
    av_assert0(k % 8 == 0);
    current->user_data_length = k /= 8;
    if (k > 0) {
        current->user_data_ref = av_buffer_alloc(k);
        if (!current->user_data_ref)
            return AVERROR(ENOMEM);
        current->user_data = current->user_data_ref->data;
    }
#endif

    for (k = 0; k < current->user_data_length; k++)
        xui(8, user_data, current->user_data[k], 0);

    return 0;
}
static int FUNC(sequence_extension)(CodedBitstreamContext *ctx, RWContext *rw,
                                    MPEG2RawSequenceExtension *current)
{
    CodedBitstreamMPEG2Context *mpeg2 = ctx->priv_data;
    int err;

    HEADER("Sequence Extension");

    ui(8,  profile_and_level_indication);
    ui(1,  progressive_sequence);
    ui(2,  chroma_format);
    ui(2,  horizontal_size_extension);
    ui(2,  vertical_size_extension);

    mpeg2->horizontal_size = (mpeg2->horizontal_size & 0xfff) |
        current->horizontal_size_extension << 12;
    mpeg2->vertical_size = (mpeg2->vertical_size & 0xfff) |
        current->vertical_size_extension << 12;
    mpeg2->progressive_sequence = current->progressive_sequence;

    ui(12, bit_rate_extension);
    marker_bit();
    ui(8,  vbv_buffer_size_extension);
    ui(1,  low_delay);
    ui(2,  frame_rate_extension_n);
    ui(5,  frame_rate_extension_d);

    return 0;
}
static int FUNC(picture_header)(CodedBitstreamContext *ctx, RWContext *rw,
                                MPEG2RawPictureHeader *current)
{
    int err;

    HEADER("Picture Header");

    ui(8,  picture_start_code);

    ui(10, temporal_reference);
    ui(3,  picture_coding_type);
    ui(16, vbv_delay);

    if (current->picture_coding_type == 2 ||
        current->picture_coding_type == 3) {
        ui(1, full_pel_forward_vector);
        ui(3, forward_f_code);
    }

    if (current->picture_coding_type == 3) {
        ui(1, full_pel_backward_vector);
        ui(3, backward_f_code);
    }

    ui(1, extra_bit_picture);

    return 0;
}
static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw,
                              MPEG2RawSliceHeader *current)
{
    CodedBitstreamMPEG2Context *mpeg2 = ctx->priv_data;
    int err;

    HEADER("Slice Header");

    ui(8, slice_vertical_position);

    if (mpeg2->vertical_size > 2800)
        ui(3, slice_vertical_position_extension);
    if (mpeg2->scalable) {
        if (mpeg2->scalable_mode == 0)
            ui(7, priority_breakpoint);
    }

    ui(5, quantiser_scale_code);

    if (nextbits(1, 1, current->slice_extension_flag)) {
        ui(1, slice_extension_flag);
        ui(1, intra_slice);
        ui(1, slice_picture_id_enable);
        ui(6, slice_picture_id);

        {
            size_t k;
#ifdef READ
            GetBitContext start;
            uint8_t bit;
            start = *rw;
            for (k = 0; nextbits(1, 1, bit); k++)
                skip_bits(rw, 8);
            current->extra_information_length = k;
            if (k > 0) {
                *rw = start;
                current->extra_information =
                    av_malloc(current->extra_information_length);
                if (!current->extra_information)
                    return AVERROR(ENOMEM);
                for (k = 0; k < current->extra_information_length; k++) {
                    xui(1, extra_bit_slice, bit, 0);
                    xui(8, extra_information_slice[k],
                        current->extra_information[k], 1, k);
                }
            }
#else
            for (k = 0; k < current->extra_information_length; k++) {
                xui(1, extra_bit_slice, 1, 0);
                xui(8, extra_information_slice[k],
                    current->extra_information[k], 1, k);
            }
#endif
        }
    }
    ui(1, extra_bit_slice);

    return 0;
}
Beispiel #18
0
	void Connection::ReadPacket()
	{
		if(Errors())
			return;
				
		/** Handle Reading Packet Type Header. **/
		if(SOCKET->available() > 0 && INCOMING->GetHeader() == 255)
		{
			std::vector<unsigned char> HEADER(1, 255);
			if(Read(HEADER, 1) == 1)
				INCOMING->SetHeader(HEADER[0]);
					
			return;
		}
				
		if(INCOMING->GetHeader() != 255 && !INCOMING->Complete())
		{
			
			/** Handle Reading Packet Length Header. **/
			if(SOCKET->available() >= 4 && INCOMING->GetLength() == 0)
			{
				std::vector<unsigned char> BYTES(4, 0);
				if(Read(BYTES, 4) == 4)
				{
					INCOMING->SetLength(BYTES);
					Event(0);
				}
					
				return;
			}
					
			/** Handle Reading Packet Data. **/
			unsigned int nAvailable = SOCKET->available();
			if(nAvailable > 0 && INCOMING->GetLength() > 0 && INCOMING->GetData().size() < INCOMING->GetLength())
			{
				std::vector<unsigned char> DATA( std::min(nAvailable, (unsigned int)(INCOMING->GetLength() - INCOMING->GetData().size())), 0);
				unsigned int nRead = Read(DATA, DATA.size());
					
				if(nRead == DATA.size())
				{
					std::vector<unsigned char> dta = INCOMING->GetData();
					try
					{
						dta.insert(dta.end(), DATA.begin(), DATA.end());
					}
					catch(const std::exception e)
					{
						return;
					}
					INCOMING->SetData(dta);

					Event(nRead);
				}
					
				return;
			}
		}
	}
Beispiel #19
0
Datei: mm.c Projekt: js6450/CSO
void *mm_realloc(void *currblock, size_t size)
{
  void *new_currblock = currblock; 
  size_t new_size = size; 
  int remainder;  
  int extendsize; 
  int block_buffer; 

  if (size == 0)
    return NULL;
  
  if (new_size <= DSIZE) {
    new_size = 2 * DSIZE;
  } else {
    new_size = DSIZE * ((new_size + (DSIZE) + (DSIZE - 1)) / DSIZE);
  }
  
  new_size += 16;
  
  block_buffer = GETSIZE(HEADER(currblock)) - new_size;
  
  if (block_buffer < 0) {
    if (!FULL(HEADER(NEXT(currblock))) || !GETSIZE(HEADER(NEXT(currblock)))) {
      remainder = GETSIZE(HEADER(currblock)) + GETSIZE(HEADER(NEXT(currblock))) - new_size;
      if (remainder < 0) {
        extendsize = ((-remainder)>CHUNKSIZE?(-remainder):CHUNKSIZE);
        if (extend_heap(extendsize) == NULL)
          return NULL;
        remainder += extendsize;
      }
      
      deletefree(NEXT(currblock));
      
      CLEARTAG(HEADER(currblock), PACK(new_size + remainder, 1)); // Block header 
      CLEARTAG(FOOTER(currblock), PACK(new_size + remainder, 1)); // Block footer 
    } else {
      new_currblock = mm_malloc(new_size - DSIZE);
      line_count--;
      memmove(new_currblock, currblock,((size)<new_size?(size):new_size));
      mm_free(currblock);
      line_count--;
    }
    block_buffer = GETSIZE(HEADER(new_currblock)) - new_size;
  }  

  if (block_buffer < 2 * 16)
    SETRTAG(HEADER(NEXT(new_currblock)));
  
  line_count++;
   if (MMCHECK) {
    mm_check('r', currblock, size);
     }
  
  return new_currblock;
}
Beispiel #20
0
void		OvMemoryPool::free_memory_debug(void* _memory)
{
	OvMemHeader*	k_mem_header = NULL;
	k_mem_header			=	HEADER(_memory);
	k_mem_header->m_iLine	=	-1;
	k_mem_header->m_pBlock	=	NULL;
	k_mem_header->mNext		=	m_pFreeMemoryList;
	m_pFreeMemoryList		=	k_mem_header;
}
static int FUNC(picture_coding_extension)(CodedBitstreamContext *ctx, RWContext *rw,
                                          MPEG2RawPictureCodingExtension *current)
{
    CodedBitstreamMPEG2Context *mpeg2 = ctx->priv_data;
    int err;

    HEADER("Picture Coding Extension");

    ui(4, f_code[0][0]);
    ui(4, f_code[0][1]);
    ui(4, f_code[1][0]);
    ui(4, f_code[1][1]);

    ui(2, intra_dc_precision);
    ui(2, picture_structure);
    ui(1, top_field_first);
    ui(1, frame_pred_frame_dct);
    ui(1, concealment_motion_vectors);
    ui(1, q_scale_type);
    ui(1, intra_vlc_format);
    ui(1, alternate_scan);
    ui(1, repeat_first_field);
    ui(1, chroma_420_type);
    ui(1, progressive_frame);

    if (mpeg2->progressive_sequence) {
        if (current->repeat_first_field) {
            if (current->top_field_first)
                mpeg2->number_of_frame_centre_offsets = 3;
            else
                mpeg2->number_of_frame_centre_offsets = 2;
        } else {
            mpeg2->number_of_frame_centre_offsets = 1;
        }
    } else {
        if (current->picture_structure == 1 || // Top field.
            current->picture_structure == 2) { // Bottom field.
            mpeg2->number_of_frame_centre_offsets = 1;
        } else {
            if (current->repeat_first_field)
                mpeg2->number_of_frame_centre_offsets = 3;
            else
                mpeg2->number_of_frame_centre_offsets = 2;
        }
    }

    ui(1, composite_display_flag);
    if (current->composite_display_flag) {
        ui(1, v_axis);
        ui(3, field_sequence);
        ui(1, sub_carrier);
        ui(7, burst_amplitude);
        ui(8, sub_carrier_phase);
    }

    return 0;
}
Beispiel #22
0
rt_private EIF_REFERENCE spclone(EIF_REFERENCE source)
{
    /* Clone an of Eiffel object `source'. Assumes that source
     * is a special object.
     */

    EIF_GET_CONTEXT
    EIF_REFERENCE result;		/* Clone pointer */
    union overhead *zone;		/* Pointer on source header */
    uint16 flags;				/* Source object flags */
    EIF_TYPE_INDEX dtype, dftype;

    if ((EIF_REFERENCE) 0 == source)
        return (EIF_REFERENCE) 0;				/* Void source */

    RT_GC_PROTECT(source);			/* Protection against GC */

    zone = HEADER(source);				/* Allocation of a new object */
    flags = zone->ov_flags;
    dtype = zone->ov_dtype;
    dftype = zone->ov_dftype;
    result = spmalloc(RT_SPECIAL_COUNT(source), RT_SPECIAL_ELEM_SIZE(source), EIF_TEST(!(flags & EO_REF)));

    /* Keep the reference flag and the composite one and the type */
    HEADER(result)->ov_flags |= flags & (EO_REF | EO_COMP);
    HEADER(result)->ov_dtype = dtype;
    HEADER(result)->ov_dftype = dftype;
    /* Keep the count and the element size */
    RT_SPECIAL_COUNT(result) = RT_SPECIAL_COUNT(source);
    RT_SPECIAL_ELEM_SIZE(result) = RT_SPECIAL_ELEM_SIZE(source);
    RT_SPECIAL_CAPACITY(result) = RT_SPECIAL_COUNT(source);

    if (!egc_has_old_special_semantic) {
        /* If by default allocation does not clear the data of a SPECIAL,
         * we actually need to do clear it otherwise we end up with a SPECIAL
         * object that is susceptible to be manipulated by the GC while waiting to
         * be filled. */
        memset(result, 0, RT_SPECIAL_VISIBLE_SIZE(result));
    }

    RT_GC_WEAN(source);				/* Remove GC protection */

    return result;
}
Beispiel #23
0
Datei: mm.c Projekt: js6450/CSO
static void placeblock(void *currblock, size_t asize)
{
  size_t currblock_size = GETSIZE(HEADER(currblock));
  size_t remainder = currblock_size - asize;
  
  deletefree(currblock);
  
  if (remainder >= 16) {
    PUT(HEADER(currblock), PACK(asize, 1));
    PUT(FOOTER(currblock), PACK(asize, 1));
    CLEARTAG(HEADER(NEXT(currblock)), PACK(remainder, 0));
    CLEARTAG(FOOTER(NEXT(currblock)), PACK(remainder, 0));  
    insertfree(NEXT(currblock), remainder);
  } else {
    PUT(HEADER(currblock), PACK(currblock_size, 1));
    PUT(FOOTER(currblock), PACK(currblock_size, 1));
  }
  return;
}
Beispiel #24
0
Symbol raw_Symbol(const wchar_t* input)
{
    uns_int size   = wcslen(input) + 1;
    Symbol result  = NEW_ARRAYED(struct Symbol_t, wchar_t[size]);
    HEADER(result) = Symbol_Class;
    result->hash   = wchar_hash(input, size);
    wcsncpy(result->value, input, size);
    result->size   = size - 1;
    return result;
}
Beispiel #25
0
/*
 * This is the core of secret sharing.  This computes the coefficients
 * used in Lagrange polynomial interpolation, returning the
 * vector of logarithms of b1(xtarget), b2(xtarget), ..., bn(xtarget).
 * Takes values from the "xCoordinate" header element, inserts the
 * results in the "lagrange" header element.
 * The interpolation values come from the headers of the "shares" array,
 * plus one additional value, xInput, which is the value we are going
 * to interpolate to.
 * 
 * Returns kPGPError_OK on success, error if not all x[i] are unique.
 */
	static PGPError
sInterp(PGPByte *shares, PGPSize bodySize, PGPByte xInput, PGPUInt32 nShares)
{
	PGPUInt32		i, j;
	PGPByte			xi, xj;
	PGPUInt32		numer, denom;

#if !PGP_STATIC_SHAMIR_ARRAYS
	s_FSetup();
#endif /* !PGP_STATIC_SHAMIR_ARRAYS */

	/* First, accumulate the numerator, Prod(xInput-x[i],i=0..n) */
	numer = 0;
	for (i = 0; i < nShares; i++)
	{
		xi = HEADER(shares,bodySize,i)->xCoordinate;
		numer += f_log[ f_sub(xi, xInput) ];
	}
	/* Preliminary partial reduction */
	numer = (numer%FIELD_SIZE) + (numer/FIELD_SIZE);

	/* Then, for each coefficient, compute the corresponding denominator */
	for (i = 0; i < nShares; i++) {
		xi = HEADER(shares,bodySize,i)->xCoordinate;
		denom = 0;
		for (j = 0; j < nShares; j++) {
			xj = (i == j) ? xInput : HEADER(shares,bodySize,j)->xCoordinate;
			if (xi == xj)
				return -1;
			denom += f_log[f_sub(xi,xj)];
		}
		denom = (denom%FIELD_SIZE)+(denom/FIELD_SIZE);
		/* 0 <= denom < 2*FIELD_SIZE-1. */

		/* Now find numer/denom.  In log form, that's a subtract. */
		denom = numer + 2*FIELD_SIZE-2 - denom;
		denom = (denom%FIELD_SIZE)+(denom/FIELD_SIZE);
		denom = (denom%FIELD_SIZE)+(denom/FIELD_SIZE);

		HEADER(shares,bodySize,i)->lagrange = (PGPByte)denom;
	}
	return kPGPError_NoErr;	/* Success */
}
Beispiel #26
0
Datei: mm.c Projekt: js6450/CSO
static void *extend_heap(size_t size)
{
  void *currblock;          
  size_t words = size / WSIZE;
  size_t asize;
  
  asize = (words % 2) ? (words + 1) * WSIZE : words * WSIZE;

  if ((long)(currblock = mem_sbrk(asize)) == -1)
    return NULL;
  
  CLEARTAG(HEADER(currblock), PACK(asize, 0)); 
  CLEARTAG(FOOTER(currblock), PACK(asize, 0));
  CLEARTAG(HEADER(NEXT(currblock)), PACK(0, 1));
  
  insertfree(currblock, asize);

  return coalesce(currblock);
}
Beispiel #27
0
Datei: mm.c Projekt: js6450/CSO
void *mm_malloc(size_t size)
{
  size_t asize; 
  void *currblock = NULL;  
  int listcounter = 0; 
  
  size_t checksize = size; // Copy of request size
  
  if (size == 0)
    return NULL;
  
  if (size <= DSIZE) {
    asize = 2 * DSIZE;
  } else {
    asize = DSIZE * ((size + DSIZE + DSIZE - 1) / DSIZE);
  }
  
  size = asize;
  for (;listcounter < LISTS; listcounter++) {
    if ((listcounter == LISTS - 1) || ((asize <= 1) && (free_lists[listcounter] != NULL))) {
      currblock = free_lists[listcounter];
      while ((currblock != NULL) && ((size > GETSIZE(HEADER(currblock))) || (RTAG(HEADER(currblock))))) {
        currblock = PREVFREE(currblock);
      }
      if (currblock != NULL)
        break;
    }   
    asize >>= 1;
  }
  
  if (currblock == NULL) {
    currblock = extend_heap(size);
  }
  
  placeblock(currblock, size);
  
  line_count++;
  if(MMCHECK)
    mm_check('a', currblock, checksize);
  
  return currblock;
}
Beispiel #28
0
void		OvMemoryPool::free_memory(void* _memory)
{

	// 鯉拭 杏嬢層 増爽社稽 巷紫瑛発 梅陥檎
	// 戚薦 増爽社研 走酔壱 陥製 企奄五乞軒稽税 爽社研 実特背層陥.
	OvMemHeader*	k_mem_header = NULL;
	k_mem_header	=	HEADER(_memory);
	k_mem_header->mNext	=	m_pFreeMemoryList;
	m_pFreeMemoryList		=	k_mem_header;

}
Beispiel #29
0
Datei: Array.c Projekt: o-/p
Array new_Array_raw(uns_int c)
{
    if (c == 0)
    {
        return empty_Array;
    }
    Array result = NEW_ARRAYED(struct Array_t, Optr[c]);
    HEADER(result) = Array_Class;
    SET_SIZE(result, c);
    return result;
}
Beispiel #30
0
Datei: mm.c Projekt: js6450/CSO
void mm_free(void *currblock)
{
  size_t size = GETSIZE(HEADER(currblock)); // Size of block 
  
  UNSETRTAG(HEADER(NEXT(currblock)));
  
  PUT(HEADER(currblock), PACK(size, 0));
  PUT(FOOTER(currblock), PACK(size, 0));
  
  insertfree(currblock, size);
  
  coalesce(currblock);
  
  line_count++;
  if (MMCHECK) {
    mm_check('f', currblock, size);
  }

  return;
}