Fixed BD_ReadSFFloat(GF_BifsDecoder * codec, GF_BitStream *bs) { if (codec->ActiveQP && codec->ActiveQP->useEfficientCoding) return gf_bifs_dec_mantissa_float(codec, bs); return FLT2FIX(gf_bs_read_float(bs)); }
void uir_load_event(GF_UIRecord *uir) { memset(&uir->next_event, 0, sizeof(GF_Event)); uir->evt_loaded = 0; if (!gf_bs_available(uir->bs)) return; uir->next_time = gf_bs_read_u32(uir->bs); uir->next_event.type = gf_bs_read_u8(uir->bs); switch (uir->next_event.type) { case GF_EVENT_CLICK: case GF_EVENT_MOUSEUP: case GF_EVENT_MOUSEDOWN: case GF_EVENT_MOUSEOVER: case GF_EVENT_MOUSEOUT: /*!! ALL MOUSE EVENTS SHALL BE DECLARED BEFORE MOUSEMOVE !! */ case GF_EVENT_MOUSEMOVE: /*mouse wheel event*/ case GF_EVENT_MOUSEWHEEL: uir->next_event.mouse.button = gf_bs_read_u8(uir->bs); uir->next_event.mouse.x = gf_bs_read_u32(uir->bs); uir->next_event.mouse.y = gf_bs_read_u32(uir->bs); uir->next_event.mouse.wheel_pos = FLT2FIX( gf_bs_read_float(uir->bs) ); uir->next_event.mouse.key_states = gf_bs_read_u8(uir->bs); break; /*Key Events*/ case GF_EVENT_KEYUP: case GF_EVENT_KEYDOWN: case GF_EVENT_LONGKEYPRESS: uir->next_event.key.key_code = gf_bs_read_u32(uir->bs); uir->next_event.key.hw_code = gf_bs_read_u32(uir->bs); uir->next_event.key.flags = gf_bs_read_u32(uir->bs); break; /*character input*/ case GF_EVENT_TEXTINPUT: uir->next_event.character.unicode_char = gf_bs_read_u32(uir->bs); break; } uir->evt_loaded = 1; }
static GF_Err IS_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 inBufferLength, u16 ES_ID, u32 AU_time, u32 mmlevel) { u32 i, j, count; Double scene_time; GF_BitStream *bs; GF_FieldInfo *field; ISStack *st; ISPriv *priv = (ISPriv *)plug->privateStack; GF_Err e = GF_OK; /*decode data frame except if local stringSensor*/ bs = gf_bs_new(inBuffer, inBufferLength, GF_BITSTREAM_READ); i=0; while ((field = (GF_FieldInfo *)gf_list_enum(priv->ddf, &i))) { /*store present flag in eventIn for command skip - this is an ugly hack but it works since DDF don't have event types*/ field->eventType = gf_bs_read_int(bs, 1); /*parse val ourselves (we don't want to depend on bifs codec)*/ if (field->eventType) { switch (field->fieldType) { case GF_SG_VRML_SFBOOL: * ((SFBool *) field->far_ptr) = (SFBool) gf_bs_read_int(bs, 1); break; case GF_SG_VRML_SFFLOAT: *((SFFloat *)field->far_ptr) = FLT2FIX( gf_bs_read_float(bs) ); break; case GF_SG_VRML_SFINT32: *((SFInt32 *)field->far_ptr) = (s32) gf_bs_read_int(bs, 32); break; case GF_SG_VRML_SFTIME: *((SFTime *)field->far_ptr) = gf_bs_read_double(bs); break; case GF_SG_VRML_SFVEC2F: ((SFVec2f *)field->far_ptr)->x = FLT2FIX( gf_bs_read_float(bs) ); ((SFVec2f *)field->far_ptr)->y = FLT2FIX( gf_bs_read_float(bs) ); break; case GF_SG_VRML_SFVEC3F: ((SFVec3f *)field->far_ptr)->x = FLT2FIX( gf_bs_read_float(bs) ); ((SFVec3f *)field->far_ptr)->y = FLT2FIX( gf_bs_read_float(bs) ); ((SFVec3f *)field->far_ptr)->z = FLT2FIX( gf_bs_read_float(bs) ); break; case GF_SG_VRML_SFCOLOR: ((SFColor *)field->far_ptr)->red = FLT2FIX( gf_bs_read_float(bs) ); ((SFColor *)field->far_ptr)->green = FLT2FIX( gf_bs_read_float(bs) ); ((SFColor *)field->far_ptr)->blue = FLT2FIX( gf_bs_read_float(bs) ); break; case GF_SG_VRML_SFVEC4F: case GF_SG_VRML_SFROTATION: ((SFRotation *)field->far_ptr)->x = FLT2FIX( gf_bs_read_float(bs) ); ((SFRotation *)field->far_ptr)->y = FLT2FIX( gf_bs_read_float(bs) ); ((SFRotation *)field->far_ptr)->z = FLT2FIX( gf_bs_read_float(bs) ); ((SFRotation *)field->far_ptr)->q = FLT2FIX( gf_bs_read_float(bs) ); break; case GF_SG_VRML_SFSTRING: { u32 size, length; size = gf_bs_read_int(bs, 5); length = gf_bs_read_int(bs, size); if (gf_bs_available(bs) < length) return GF_NON_COMPLIANT_BITSTREAM; if ( ((SFString *)field->far_ptr)->buffer ) gf_free( ((SFString *)field->far_ptr)->buffer); ((SFString *)field->far_ptr)->buffer = (char*)gf_malloc(sizeof(char)*(length+1)); memset(((SFString *)field->far_ptr)->buffer , 0, length+1); for (j=0; j<length; j++) { ((SFString *)field->far_ptr)->buffer[j] = gf_bs_read_int(bs, 8); } } break; } } } gf_bs_del(bs); /*special case for StringSensor in local mode: lookup for special chars*/ if ((priv->type == IS_StringSensor) && priv->is_local) { char tmp_utf8[5000]; const unsigned short *ptr; u32 len; GF_FieldInfo *field1 = (GF_FieldInfo *)gf_list_get(priv->ddf, 0); GF_FieldInfo *field2 = (GF_FieldInfo *)gf_list_get(priv->ddf, 1); SFString *inText = (SFString *) field1->far_ptr; SFString *outText = (SFString *) field2->far_ptr; field1->eventType = field2->eventType = 0; priv->enteredText[priv->text_len] = (short) '\0'; len = gf_utf8_wcslen(priv->enteredText); if (len && (priv->enteredText[len-1] == priv->termChar)) { ptr = priv->enteredText; len = gf_utf8_wcstombs(tmp_utf8, 5000, &ptr); if (outText->buffer) gf_free(outText->buffer); outText->buffer = (char*)gf_malloc(sizeof(char) * (len)); memcpy(outText->buffer, tmp_utf8, sizeof(char) * len-1); outText->buffer[len-1] = 0; if (inText->buffer) gf_free(inText->buffer); inText->buffer = NULL; priv->text_len = 0; field1->eventType = field2->eventType = 1; } else { if (priv->delChar) { /*remove chars*/ if ((len>1) && (priv->enteredText[len-1] == priv->delChar)) { priv->enteredText[len-1] = (short) '\0'; len--; if (len) { priv->enteredText[len-1] = (short) '\0'; len--; } } } priv->text_len = len; ptr = priv->enteredText; len = gf_utf8_wcstombs(tmp_utf8, 5000, &ptr); if (inText->buffer) gf_free(inText->buffer); inText->buffer = (char*)gf_malloc(sizeof(char) * (len+1)); memcpy(inText->buffer, tmp_utf8, sizeof(char) * len); inText->buffer[len] = 0; field1->eventType = 1; } } gf_term_lock_compositor(priv->scene->root_od->term, 1); /*apply it*/ i=0; while ((st = (ISStack*)gf_list_enum(priv->is_nodes, &i))) { assert(st->is); assert(st->mo); if (!st->is->enabled) continue; count = gf_list_count(st->is->buffer.commandList); scene_time = gf_scene_get_time(priv->scene); for (j=0; j<count; j++) { GF_Command *com = (GF_Command *)gf_list_get(st->is->buffer.commandList, j); GF_FieldInfo *field = (GF_FieldInfo *)gf_list_get(priv->ddf, j); GF_CommandField *info = (GF_CommandField *)gf_list_get(com->command_fields, 0); if (info && field && field->eventType) { gf_sg_vrml_field_copy(info->field_ptr, field->far_ptr, field->fieldType); gf_sg_command_apply(priv->scene->graph, com, scene_time); } } } gf_term_lock_compositor(priv->scene->root_od->term, 0); return e; }
GF_Err gf_odf_parse_qos(GF_BitStream *bs, GF_QoS_Default **qos_qual, u32 *qual_size) { u32 tag, qos_size, val, bytesParsed, sizeHeader; GF_QoS_Default *newQoS; //tag tag = gf_bs_read_int(bs, 8); bytesParsed = 1; //size of instance qos_size = 0; sizeHeader = 0; do { val = gf_bs_read_int(bs, 8); sizeHeader++; qos_size <<= 7; qos_size |= val & 0x7F; } while ( val & 0x80 ); bytesParsed += sizeHeader; //Payload switch (tag) { case QoSMaxDelayTag: newQoS = (GF_QoS_Default *) gf_malloc(sizeof(GF_QoS_MaxDelay)); ((GF_QoS_MaxDelay *)newQoS)->MaxDelay = gf_bs_read_int(bs, 32); bytesParsed += 4; break; case QoSPrefMaxDelayTag: newQoS = (GF_QoS_Default *) gf_malloc(sizeof(GF_QoS_PrefMaxDelay)); ((GF_QoS_PrefMaxDelay *)newQoS)->PrefMaxDelay = gf_bs_read_int(bs, 32); bytesParsed += 4; break; case QoSLossProbTag: newQoS = (GF_QoS_Default *) gf_malloc(sizeof(GF_QoS_LossProb)); ((GF_QoS_LossProb *)newQoS)->LossProb = gf_bs_read_float(bs); bytesParsed += 4; break; case QoSMaxGapLossTag: newQoS = (GF_QoS_Default *) gf_malloc(sizeof(GF_QoS_MaxGapLoss)); ((GF_QoS_MaxGapLoss *)newQoS)->MaxGapLoss = gf_bs_read_int(bs, 32); bytesParsed += 4; break; case QoSMaxAUSizeTag: newQoS = (GF_QoS_Default *) gf_malloc(sizeof(GF_QoS_MaxAUSize)); ((GF_QoS_MaxAUSize *)newQoS)->MaxAUSize = gf_bs_read_int(bs, 32); bytesParsed += 4; break; case QoSAvgAUSizeTag: newQoS = (GF_QoS_Default *) gf_malloc(sizeof(GF_QoS_AvgAUSize)); ((GF_QoS_AvgAUSize *)newQoS)->AvgAUSize = gf_bs_read_int(bs, 32); bytesParsed += 4; break; case QoSMaxAURateTag: newQoS = (GF_QoS_Default *) gf_malloc(sizeof(GF_QoS_MaxAURate)); ((GF_QoS_MaxAURate *)newQoS)->MaxAURate = gf_bs_read_int(bs, 32); bytesParsed += 4; break; case 0x00: case 0xFF: return GF_ODF_FORBIDDEN_DESCRIPTOR; default: //we defined the private qos... newQoS = (GF_QoS_Default *) gf_malloc(sizeof(GF_QoS_Private)); ((GF_QoS_Private *)newQoS)->DataLength = qos_size; gf_bs_read_data(bs, ((GF_QoS_Private *)newQoS)->Data, ((GF_QoS_Private *)newQoS)->DataLength); bytesParsed += ((GF_QoS_Private *)newQoS)->DataLength; break; } newQoS->size = qos_size; newQoS->tag = tag; if (bytesParsed != 1 + qos_size + sizeHeader) { gf_odf_delete_qos_qual(newQoS); return GF_ODF_INVALID_DESCRIPTOR; } *qos_qual = newQoS; *qual_size = bytesParsed; return GF_OK; }