//-------------------------------------------------------------------------- int tms_realcvt(void *m, ushort *e, ushort swt) { int ret; int32 A; int16 B; union { float pfl; int32 pint; }; switch ( swt ) { case 0: // TmsFloat 16bit to e { memcpy(&B, m, 2); pfl = conv16(B); pint = swap32(pint); ret = ieee_realcvt(&pint, e, 1); break; } case 1: // TmsFloat 32bit to e { memcpy(&A, m, 4); pfl = conv32(A); pint = swap32(pint); ret = ieee_realcvt(&pint, e, 1); break; } default: msg("real_cvt_error swt = %d \n", swt); return -1; } return ret; }
void printQJST(qjst *p) { int i,j; char index[32]; SMFPRINTSTART("QJST", p, conv16(p->qjstll)); ADDS32("WRT_Request_Wait" ,p->qjstwrw ); ADDS32("WRT_Request_NoWait" ,p->qjstwrnw); ADDS32("WRT_Request_Force" ,p->qjstwrf ); ADDS32("Unavailable_Buffer_Count",p->qjstwtb ); ADDS32("Log_Read_Output_Buffer",p->qjstrbuf); ADDS32("Log_Read_Active_Log" ,p->qjstract); ADDS32("Log_Read_Archive_Log" ,p->qjstrarh); ADDS32("Tape_Contention_Delays",p->qjsttvc ); ADDS32("BSDS_Access " ,p->qjstbsds); ADDS32("Active_Log_CI" ,p->qjstbffl); ADDS32("Buffer_Writes" ,p->qjstbfwr); ADDS32("Archive_Read" ,p->qjstalr ); ADDS32("Archive_Write" ,p->qjstalw ); ADDS32("CI_Offloads" ,p->qjstciof); ADDS32("Checkpoints" ,p->qjstllcp); ADDS32("Read_Delayed" ,p->qjstwur ); ADDS32("Lookahead_Mount_Attempts",p->qjstlama); ADDS32("Lookahead_Mount_Succeed",p->qjstlams); ADDS32("Log_Request_Suspends" ,p->qjstlsus); ADDS32("Log_Writes" ,p->qjstlogw); ADDS32("Log_CI" ,p->qjstciwr); ADDS32("Log_CI_Serial" ,p->qjstserw); ADDS32("Log_Write_Threshold" ,p->qjstthrw); ADDS32("Log_Write_Buffer_Paged",p->qjstbpag); if (conv16(p->qjstll)>=offsetof(qjst,qjstio)) { /* Array of 1 entry! Reserved space follows for 2 more, but they */ /* are not currently used. If the others are ever used, change the */ /* macro to use ADDSxxIDX */ for (i=0;i<1;i++) { if (first) sprintf(index,"%d",i+1); ADDS32("Comp_Requests" , p->qjstcompr[i].qjstcmpreq); ADDS32("Comp_Fail" , p->qjstcompr[i].qjstcmpfail); ADDS64("Comp_Uncompressed_Bytes" , p->qjstcompr[i].qjstcmpuncmp); ADDS64("Comp_Compressed_Bytes" , p->qjstcompr[i].qjstcmpcomp); ADDS32("Decomp_Requests" , p->qjstcompr[i].qjstdecreq); ADDS32("Decomp_Fail" , p->qjstcompr[i].qjstdecfail); ADDS64("Decomp_Uncompressed_Bytes", p->qjstcompr[i].qjstdecuncmp); ADDS64("Decomp_Compressed_Bytes" , p->qjstcompr[i].qjstdeccomp); } } if (conv16(p->qjstll)>=offsetof(qjst,qjstio[0])) { for (i=0;i<2;i++) { for (j=0;j<2;j++) { if (first) sprintf(index,"%d.%d",i+1,j+1); ADDU32IDX("IO_Count" , index , p->qjstio[i].qjstiotype[j].qjstiocount); ADDU32IDX("IO_CI" , index , p->qjstio[i].qjstiotype[j].qjstioci); ADDSTCKIDX("IO_Total_Time", index , p->qjstio[i].qjstiotype[j].qjstiototio); ADDSTCKIDX("IO_Total_Suspend_Time", index , p->qjstio[i].qjstiotype[j].qjstiototsus); ADDSTCKIDX("IO_Max_Duration" , index , p->qjstio[i].qjstiotype[j].qjstiomaxio); ADDTIMEIDX("IO_Max_Time" , index ,p->qjstio[i].qjstiotype[j].qjstiomaxioT); ADDSTRENIDX("IO_Max_Log_ID" , index , p->qjstio[i].qjstiotype[j].qjstiomaxiol,8); ADDSTCKIDX("IO_Max_Suspend_Dur" , index, p->qjstio[i].qjstiotype[j].qjstiomaxsus); ADDTIMEIDX("IO_Max_Suspend_Time" , index, p->qjstio[i].qjstiotype[j].qjstiomaxsusT); ADDSTRENIDX("IO_Max_Suspend_Log_ID" , index, p->qjstio[i].qjstiotype[j].qjstiomaxsusl,8); } } ADDTIME("Writer_Idle_Time" , p->qjstslptu); ADDU64 ("IO_Time_Sum_Squares_1", p->qjstiosqu[0]); ADDU64 ("IO_Time_Sum_Squares_2", p->qjstiosqu[1]); } /* MQ 9.1.2 added support for zHyperwrite logging */ if (conv16(p->qjstll)>=offsetof(qjst,qjstcp1n)) { ADDS32("Copy1_New_Logs" , p->qjstcp1n); ADDS32("Copy2_New_Logs" , p->qjstcp2n); ADDS32("New_Logs_ZHW_Capable" , p->qjsthwc); ADDS32("New_Logs_ZHW_Enabled" , p->qjsthwe); } SMFPRINTSTOP; return; }
/*------------------------------------------------------------------------------ * Write data to the encoder *----------------------------------------------------------------------------*/ unsigned int LameLibEncoder :: write ( const void * buf, unsigned int len ) throw ( Exception ) { if ( !isOpen() ) { return 0; } unsigned int bitsPerSample = getInBitsPerSample(); unsigned int channels = getInChannel(); if ( channels != 1 && channels != 2 ) { throw Exception( __FILE__, __LINE__, "unsupported number of channels for the encoder", channels ); } unsigned int sampleSize = (bitsPerSample / 8) * channels; unsigned char * b = (unsigned char*) buf; unsigned int processed = len - (len % sampleSize); unsigned int nSamples = processed / sampleSize; short int leftBuffer[nSamples]; short int rightBuffer[nSamples]; if ( bitsPerSample == 8 ) { conv8( b, processed, leftBuffer, rightBuffer, channels); } else if ( bitsPerSample == 16 ) { conv16( b, processed, leftBuffer, rightBuffer, channels); } else { throw Exception( __FILE__, __LINE__, "unsupported number of bits per sample for the encoder", bitsPerSample ); } // data chunk size estimate according to lame documentation unsigned int mp3Size = (unsigned int) (1.25 * nSamples + 7200); unsigned char mp3Buf[mp3Size]; int ret; ret = lame_encode_buffer( lameGlobalFlags, leftBuffer, channels == 2 ? rightBuffer : leftBuffer, nSamples, mp3Buf, mp3Size ); if ( ret < 0 ) { reportEvent( 3, "lame encoding error", ret); return 0; } unsigned int written = sink->write( mp3Buf, ret); // just let go data that could not be written if ( written < (unsigned int) ret ) { reportEvent( 2, "couldn't write all from encoder to underlying sink", ret - written); } return processed; }
// ============================================================ // Author : Scott Kirkwood // Date : Tue Nov 10 1992 // // Prototype : iformat.h // Description : // Main routine, handles output of unsigned longs. // Note: setting width to anything but 0 causes a big speed penalty. // const char *IFormat::Str(unsigned long num, int neg) { int as = 0; int old_putseps = putseps; // Commas will move the string to the right need 2 bytes for // the potential SI postfix and the null. char *last = str + sizeof(str) - IFormatMaxCommas - 2; char *first; int len = 0; if (width) { if (use_si) { int tempwidth = width; register unsigned long tempnum = num; while (as < IFormatMAXSI - 1 && Size(tempnum, neg) > tempwidth) { if (as == 0) tempwidth--; // because of the postfix character as++; tempnum = num / divby[as]; } num = tempnum; } else { if (putseps && Size(num, neg) > width) { putseps = 0; if (Size(num, neg) > width) putseps = old_putseps; } } } // The converter routines grows the string backwards from the least sig. // digit to the m.s. digit. No null is placed. switch (mode) { case ios::hex: first = conv16(num, last, len); break; case ios::oct: first = conv8(num, last, len); break; default: first = uconv10(num, last, len); break; } last++; *last = 0; if (putseps) PutCommas(last, len); if (neg) { first--; *first = '-'; len++; } if (width) { if (use_si && as) { *last++ = ext[as]; *last = 0; len++; } if (right_adjust) RightAdjust(first, len, width); } putseps = old_putseps; return first; }