FIO_DP_TO_FT_FUNC(wav,Wav_Header) { /* num_frame set when when write request given */ /* BUG questionable cast */ hd_p->wh_n_channels = (short) OBJ_COMPS(dp); switch( OBJ_MACH_PREC(dp) ){ case PREC_UBY: hd_p->wh_bits_per_sample = 8; break; case PREC_IN: hd_p->wh_bits_per_sample = 16; break; default: sprintf(ERROR_STRING, "dp_to_wav: vector %s has unsupported source precision %s", OBJ_NAME(dp),PREC_NAME(OBJ_MACH_PREC_PTR(dp))); warn(ERROR_STRING); return(-1); break; } hd_p->wh_datasize = OBJ_N_TYPE_ELTS(dp) * PREC_SIZE( OBJ_MACH_PREC_PTR(dp) ); hd_p->wh_chunksize = 36 + hd_p->wh_datasize; /* BUG dp's don't have a way to carry around the sample rate with them??? */ /* So we assume that the current sample rate is the one that corresponds * to this object BUG */ hd_p->wh_samp_rate = (*samp_rate_func)(); hd_p->wh_blk_align = hd_p->wh_n_channels * hd_p->wh_bits_per_sample / 8; hd_p->wh_bytes_per_sec = hd_p->wh_blk_align * hd_p->wh_samp_rate; return 0; }
int xform_chk(Data_Obj *dpto,Data_Obj *dpfr,Data_Obj *xform) { if( dpto==NO_OBJ || dpfr==NO_OBJ || xform==NO_OBJ ) return(-1); if( !IS_IMAGE(xform) ){ sprintf(DEFAULT_ERROR_STRING, "xform_chk: transformation %s must be a matrix (image)", OBJ_NAME(xform)); NWARN(DEFAULT_ERROR_STRING); return(-1); } if( OBJ_COMPS(xform) != 1 ){ sprintf(DEFAULT_ERROR_STRING, "xform_chk: transform matrix %s must have single-component elements",OBJ_NAME(xform)); NWARN(DEFAULT_ERROR_STRING); return(-1); } if( OBJ_COMPS(dpto) != OBJ_ROWS(xform) ){ sprintf(DEFAULT_ERROR_STRING, "xform_chk: target %s component dimension (%d) must match # rows of xform %s (%d)", OBJ_NAME(dpto),OBJ_COMPS(dpto),OBJ_NAME(xform),OBJ_ROWS(xform)); NWARN(DEFAULT_ERROR_STRING); return(-1); } if( OBJ_COMPS(dpfr) != OBJ_COLS(xform) ){ sprintf(DEFAULT_ERROR_STRING, "xform_chk: source %s component dimension (%d) must match # columns of xform %s (%d)", OBJ_NAME(dpto),OBJ_COMPS(dpto),OBJ_NAME(xform),OBJ_ROWS(xform)); NWARN(DEFAULT_ERROR_STRING); return(-1); } if( OBJ_N_TYPE_ELTS(dpto)/OBJ_COMPS(dpto) != OBJ_N_TYPE_ELTS(dpfr)/OBJ_COMPS(dpfr) ){ sprintf(DEFAULT_ERROR_STRING, "xform_chk: target %s (%d/%d) and source %s (%d/%d) must have same # of elements", OBJ_NAME(dpto),OBJ_N_TYPE_ELTS(dpto),OBJ_COMPS(dpto), OBJ_NAME(dpfr),OBJ_N_TYPE_ELTS(dpfr),OBJ_COMPS(dpfr)); NWARN(DEFAULT_ERROR_STRING); return(-1); } /* BUG these contiguity requirements may no longer be necessary... */ if( !is_contiguous(DEFAULT_QSP_ARG dpto) ){ sprintf(DEFAULT_ERROR_STRING, "xform_chk: xform target %s must be contiguous",OBJ_NAME(dpto)); NWARN(DEFAULT_ERROR_STRING); return(-1); } if( !is_contiguous(DEFAULT_QSP_ARG dpfr) ){ sprintf(DEFAULT_ERROR_STRING, "xform_chk: xform source %s must be contiguous",OBJ_NAME(dpfr)); NWARN(DEFAULT_ERROR_STRING); return(-1); } if( !is_contiguous(DEFAULT_QSP_ARG xform) ){ sprintf(DEFAULT_ERROR_STRING, "xform_chk: xform %s must be contiguous",OBJ_NAME(xform)); NWARN(DEFAULT_ERROR_STRING); return(-1); } return(0); } // end xform_chk