IoObject *IoODEMass_parameters(IoODEMass *self, IoObject *locals, IoMessage *m) { // vector(theMass, cgx, cgy, cgz, I11, I22, I33, I12, I13, I23) UArray *u = UArray_new(); int i, j = 0; UArray_setItemType_(u, CTYPE_float32_t); UArray_setSize_(u, 10); UArray_at_putDouble_(u, j++, DATA(self)->mass); for(i=0; i < 3; i++) { UArray_at_putDouble_(u, j++, DATA(self)->c[i]); } // 0 1 2 3 4 5 6 7 8 9 10 11 // I == vector(I11, I12, I13, _, I12, I22, I23, _, I13, I23, I33, _) UArray_at_putDouble_(u, j++, DATA(self)->I[0 ]); // I11 UArray_at_putDouble_(u, j++, DATA(self)->I[5 ]); // I22 UArray_at_putDouble_(u, j++, DATA(self)->I[10]); // I33 UArray_at_putDouble_(u, j++, DATA(self)->I[1 ]); // I12 UArray_at_putDouble_(u, j++, DATA(self)->I[2 ]); // I13 UArray_at_putDouble_(u, j++, DATA(self)->I[6 ]); // I23 return IoSeq_newWithUArray_copy_(IOSTATE, u, 1); }
IoObject *IoODEBody_quaternion(IoODEBody *self, IoObject *locals, IoMessage *m) { IoODEBody_assertValidBody(self, locals, m); { const dReal *q = dBodyGetQuaternion(BODYID); IoSeq *v = IoSeq_newFloatArrayOfSize_(IOSTATE, 4); UArray *u = IoSeq_rawUArray(v); UArray_at_putDouble_(u, 0, q[0]); UArray_at_putDouble_(u, 1, q[1]); UArray_at_putDouble_(u, 2, q[2]); UArray_at_putDouble_(u, 3, q[3]); return v; } }
IoObject *IoODEBody_rotation(IoODEBody *self, IoObject *locals, IoMessage *m) { IoODEBody_assertValidBody(self, locals, m); { const dReal *R = dBodyGetRotation(BODYID); IoSeq *v = IoSeq_newFloatArrayOfSize_(IOSTATE, 9); UArray *u = IoSeq_rawUArray(v); UArray_at_putDouble_(u, 0, R[0]); UArray_at_putDouble_(u, 1, R[4]); UArray_at_putDouble_(u, 2, R[8]); UArray_at_putDouble_(u, 3, R[1]); UArray_at_putDouble_(u, 4, R[5]); UArray_at_putDouble_(u, 5, R[9]); UArray_at_putDouble_(u, 6, R[2]); UArray_at_putDouble_(u, 7, R[6]); UArray_at_putDouble_(u, 8, R[10]); return v; } }
IoObject *IoODEMass_inertiaTensor(IoODEMass *self, IoObject *locals, IoMessage *m) { UArray *u = UArray_new(); int i, j; UArray_setItemType_(u, CTYPE_float32_t); UArray_setSize_(u, 9); // I == vector(I11, I12, I13, _, I12, I22, I23, _, I13, I23, I33, _) for(i = 0, j = 0; i < 12; i++) { if ((i + 1) % 4) { UArray_at_putDouble_(u, j++, DATA(self)->I[i]); } } return IoSeq_newWithUArray_copy_(IOSTATE, u, 1); }
IO_METHOD(IoSeq, atPut) { /*doc Sequence atPut(aNumberIndex, aNumber) Sets the value at the index specified by aNumberIndex to aNumber. Returns self. */ size_t i = IoMessage_locals_longArgAt_(m, locals, 0); UArray *a = DATA(self); IO_ASSERT_NOT_SYMBOL(self); if (UArray_isFloatType(a)) { double v = IoMessage_locals_doubleArgAt_(m, locals, 1); UArray_at_putDouble_(a, i, v); } else { long v = IoMessage_locals_longArgAt_(m, locals, 1); UArray_at_putLong_(a, i, v); } return self; }
int IoAVCodec_findStreams(IoAVCodec *self) { AVFormatContext *formatContext = DATA(self)->formatContext; int i; av_find_stream_info(formatContext); //printf("formatContext = %p streams = %i\n", (void *)formatContext, formatContext->nb_streams); for(i = 0; i < formatContext->nb_streams; i++) { AVStream *stream = formatContext->streams[i]; AVCodecContext *codecContext = stream->codec; switch(codecContext->codec_type) { case CODEC_TYPE_AUDIO: DATA(self)->audioStreamIndex = i; { AVCodec *codec = avcodec_find_decoder(codecContext->codec_id); if (codec) { int err = avcodec_open(codecContext, codec); if (err == 0) { DATA(self)->audioContext = codecContext; } } } //printf("audioStreamIndex = %i\n", DATA(self)->audioStreamIndex); IoObject_setSlot_to_(self, IOSYMBOL("audioChannels"), IONUMBER(codecContext->channels)); IoObject_setSlot_to_(self, IOSYMBOL("audioSampleRate"), IONUMBER(codecContext->sample_rate)); IoObject_setSlot_to_(self, IOSYMBOL("audioBitRate"), IONUMBER(codecContext->bit_rate)); IoObject_setSlot_to_(self, IOSYMBOL("audioDuration"), IONUMBER(stream->duration)); IoObject_setSlot_to_(self, IOSYMBOL("audioFrameCount"), IONUMBER(stream->nb_frames)); break; case CODEC_TYPE_VIDEO: { DATA(self)->videoStreamIndex = i; { AVCodec *codec = avcodec_find_decoder(codecContext->codec_id); if (codec) { int err = avcodec_open(codecContext, codec); if (err == 0) { DATA(self)->videoContext = codecContext; } } } //printf("videoStreamIndex = %i\n", DATA(self)->videoStreamIndex); { float framePeriod = (((float)codecContext->time_base.num)/((float)codecContext->time_base.den)); //UArray *sizeUArray = UArray_newWithData_type_encoding_size_copy_("", CTYPE_float32_t, CENCODING_NUMBER, 2, 1); IoObject_setSlot_to_(self, IOSYMBOL("framePeriod"), IONUMBER(framePeriod)); IoObject_setSlot_to_(self, IOSYMBOL("videoDuration"), IONUMBER(stream->duration)); IoObject_setSlot_to_(self, IOSYMBOL("videoFrameCount"), IONUMBER(stream->nb_frames)); } { UArray *sizeUArray = UArray_newWithData_type_encoding_size_copy_("", CTYPE_float32_t, CENCODING_NUMBER, 2, 1); IoSeq *sizeSeq = IoSeq_newWithUArray_copy_(IOSTATE, sizeUArray, 0); UArray_at_putDouble_(sizeUArray, 0, codecContext->width); UArray_at_putDouble_(sizeUArray, 1, codecContext->height); IoObject_setSlot_to_(self, IOSYMBOL("videoSize"), sizeSeq); } break; } case CODEC_TYPE_UNKNOWN: continue; case CODEC_TYPE_DATA: continue; case CODEC_TYPE_SUBTITLE: continue; case CODEC_TYPE_NB: continue; default: continue; } } return 0; }
static void UArray_setXY(UArray *self, double x, double y) { UArray_at_putDouble_(self, 0, x); UArray_at_putDouble_(self, 1, y); }