XILWindowAssistor::~XILWindowAssistor() { //fprintf(stderr,"XILWindowAssistor::~XILWindowAssistor\n"); if (cis_) { xil_cis_sync(cis_); xil_cis_destroy(cis_); cis_ = 0; } /* * Clear out the image so that the Video class does * not try to use it before another window gets attached * and replaces the image. */ if (window_) { window_->setimage(0); // Tk_FreeGC(Tk_Display(window_->tkwin()), gc_); XFreeGC(Tk_Display(window_->tkwin()), gc_); } if (ximage_) xil_destroy(ximage_); if (displayimage_) { xil_set_attribute(displayimage_,"HW_DECOMPRESS_CIS",NULL); xil_destroy(displayimage_); } if (imageYCC) xil_destroy(imageYCC); /* if (xil_) { xil_close(xil_);xil_=0; } */ }
static void updateXilImages(InstanceState *inst) { /* Debug Message */ PRINT("In updateXilImages\n"); if (!inst || !inst->started) return; if (inst->scaled_image) { xil_destroy(inst->scaled_image); inst->scaled_image = NULL; } if (inst->colored_image) { xil_destroy(inst->colored_image); inst->colored_image = NULL; } /* * At this point, rtvc_image is valid but nothing else is. * Construct the rest of the images needed. */ if (inst->scale != 1) { inst->outWidth = (int) (((float) inst->inWidth / inst->scale) + 0.5); inst->outHeight = (int) (((float) inst->inHeight / inst->scale) + 0.5); inst->sx = 1.0 / (float) inst->scale; inst->sy = 1.0 / (float) inst->scale; inst->scaled_image = xil_create(inst->xil_state, inst->outWidth, inst->outHeight, inst->inBands, XIL_BYTE); } else { inst->outWidth = inst->inWidth; inst->outHeight = inst->inHeight; } if (inst->do_cis == RAW) { XilColorspace xil_cspace_ycc601; /* YCC CCIR 601 colorspace */ XilColorspace xil_cspace_rgb709; /* RGB CCIR 709 colorspace */ xil_cspace_ycc601 = xil_colorspace_get_by_name(inst->xil_state, "ycc601"); xil_cspace_rgb709 = xil_colorspace_get_by_name(inst->xil_state, "rgb709"); inst->colored_image = xil_create(inst->xil_state, inst->outWidth, inst->outHeight, inst->inBands, XIL_BYTE); xil_set_colorspace(inst->rtvc_image, xil_cspace_ycc601); if (inst->scaled_image) xil_set_colorspace(inst->scaled_image, xil_cspace_ycc601); xil_set_colorspace(inst->colored_image, xil_cspace_rgb709); } else { updateXilCis(inst); } }
XILOutputAssistor::~XILOutputAssistor() { xil_set_attribute(o1kimage,"HW_DECOMPRESS_CIS",NULL); if (o1kimage) xil_destroy(o1kimage); if (cis_) xil_cis_destroy(cis_); /* if (xil_) {xil_close(xil_);xil_=0;} */ }
static void freeXilImages(InstanceState *inst) { /* Debug Message */ PRINT("In freeXilImages\n"); if (inst) { if (inst->scaled_image) { xil_destroy(inst->scaled_image); inst->scaled_image = NULL; } if (inst->colored_image) { xil_destroy(inst->colored_image); inst->colored_image = NULL; } freeXilCis(inst); } }
static void freeXilState(JNIEnv *env, jobject jxil, InstanceState *inst) { /* Debug Message */ PRINT("In freeXilState\n"); if (inst) { if (inst->rtvc_image) { xil_destroy(inst->rtvc_image); inst->rtvc_image = NULL; } freeXilImages(inst); if (inst->xil_state) { /* xil_close(inst->xil_state); */ inst->xil_state = NULL; } SetLongField(env, jxil, "peer", (int) 0); free(inst); } }
int XILOutputAssistor::consume(const VideoFrame* vf) { int len=0,dofree=0; u_char *bp,*p=NULL; //fprintf(stderr,"XILOutputAssistor(%s)::"__FUNCTION__"\n",filename_); switch (type_) { case FT_JPEG|FT_HW: { JpegFrame* jf = (JpegFrame*)vf; if ( (jf->q_ != inq_) || (jf->width_ != width_) || (jf->height_ != height_) ) reset(jf->q_, jf->width_, jf->height_); len=jf->len_; bp=jf->bp_; dofree=1; if (sentfirstheader) { p = new u_char[sizeof(jfif_header2)+len]; memcpy(p,jfif_header2,sizeof(jfif_header2)); memcpy(p+sizeof(jfif_header2),bp,len); len+=sizeof(jfif_header2); } else { p = new u_char [sizeof(jfif_header1)+len]; memcpy(p,jfif_header1,sizeof(jfif_header1)); memcpy(p+sizeof(jfif_header1),bp,len); len+=sizeof(jfif_header1); sentfirstheader=1; } break; } case FT_CELLB: { CellBFrame* hf = (CellBFrame*) vf; len=hf->len_; p=hf->bp_; xil_cis_set_attribute(cis_, "WIDTH", (void *)hf->width_); xil_cis_set_attribute(cis_, "HEIGHT", (void *)hf->height_); break; } case FT_H261: { H261Frame* hf = (H261Frame*) vf; len=hf->len_; p=hf->bp_; while ((p[0]==0)&&(p[1]==0)) { p++;len--; } break; } } xil_cis_put_bits(cis_,len,1/*framecount*/,p); if (dofree) delete[] p; //SV-XXX: Debian outputtype = xil_cis_get_output_type(cis_); xil_imagetype_get_info(outputtype, &cis_xsize, &cis_ysize,&cis_nbands, &cis_datatype); if (!imageYCC || lastcisw!=cis_xsize || lastcish!=cis_ysize) { lastcish = cis_ysize; lastcisw = cis_xsize; //fprintf(stderr," w=%d,h=%d\n",cis_xsize,cis_ysize); if (imageYCC) xil_destroy(imageYCC); imageYCC = xil_create(xil_,cis_xsize,cis_ysize,cis_nbands,cis_datatype); return 0; } xil_decompress(cis_, imageYCC); xil_sync(imageYCC); //xil_cis_reset(cis_); return (0); }
int XILWindowAssistor::consume(const VideoFrame* vf) { int len=0,dofree=0; u_char *bp,*p=NULL; float scale[3], offset[3]; XilColorspace ycc, rgb; // fprintf(stderr,"XILWindowAssistor::"__FUNCTION__"\n"); switch (type_) { case FT_JPEG|FT_HW: { JpegFrame* jf = (JpegFrame*)vf; if ( (jf->type_ != lastjpegtype_) || (jf->q_ != inq_) || (jf->width_ != width_) || (jf->height_ != height_) ) { //fprintf(stderr,"w=%d,h=%d,q=%d\n",jf->width_,jf->height_,jf->q_); reset(jf->type_,jf->q_, jf->width_, jf->height_); } len=jf->len_; bp=jf->bp_; dofree=1; if (sentfirstheader) { p = new u_char[sizeof(jfif_header2)+len]; memcpy(p,jfif_header2,sizeof(jfif_header2)); memcpy(p+sizeof(jfif_header2),bp,len); len+=sizeof(jfif_header2); } else { p = new u_char[sizeof(jfif_header1)+len]; memcpy(p,jfif_header1,sizeof(jfif_header1)); memcpy(p+sizeof(jfif_header1),bp,len); len+=sizeof(jfif_header1); sentfirstheader=1; } break; } case FT_CELLB: { CellBFrame* hf = (CellBFrame*) vf; len=hf->len_; p=hf->bp_; xil_cis_set_attribute(cis_, "WIDTH", (void *)hf->width_); xil_cis_set_attribute(cis_, "HEIGHT", (void *)hf->height_); break; } case FT_H261: { H261Frame* hf = (H261Frame*) vf; len=hf->len_; p=hf->bp_; //Don't accept double zero bytes. xil chokes on that. while ((p[0]==0)&&(p[1]==0)&&len) { p++;len--; } break; } } xil_cis_put_bits(cis_,len,1/*framecount*/,p); if (dofree) delete[] p; //move this to the end, if you use put_bits_ptr //SV-XXX: Debian outputtype = xil_cis_get_output_type(cis_); xil_imagetype_get_info(outputtype, &cis_xsize, &cis_ysize,&cis_nbands, &cis_datatype); if (!imageYCC || (lastcisw!=cis_xsize) || (lastcish!=cis_ysize)) { lastcish = cis_ysize; lastcisw = cis_xsize; //fprintf(stderr," w=%d,h=%d,b=%d,t=%d\n",cis_xsize,cis_ysize,cis_nbands,cis_datatype); if (imageYCC) xil_destroy(imageYCC); if (ximage_) xil_destroy(ximage_); ximage_ = xil_create(xil_,cis_xsize,cis_ysize,cis_nbands,cis_datatype); imageYCC = xil_create(xil_,cis_xsize,cis_ysize,cis_nbands,cis_datatype); } if (visual == PSEUDOCOLOR) { scale[0] = 255.0 / (235.0 - 16.0); scale[1] = 255.0 / (240.0 - 16.0); scale[2] = 255.0 / (240.0 - 16.0); offset[0] = -16.0 * scale[0]; offset[1] = -16.0 * scale[1]; offset[2] = -16.0 * scale[2]; if (!x_cmap) { colorcube = xil_lookup_get_by_name(xil_, "cc855"); dmask = xil_dithermask_get_by_name(xil_, "dm443"); xil_cmap = create_cmap(&x_cmap, FT_JPEG, NULL, xil_lookup_get_by_name(xil_, "yuv_to_rgb"), colorcube ); } /* Begin XIL Molecule... */ xil_decompress( cis_, imageYCC ); xil_rescale(imageYCC, imageYCC, scale, offset); xil_scale(imageYCC,ximage_,"nearest",(1.0*targetw_)/lastcisw,(1.0*targeth_)/lastcish); xil_ordered_dither( ximage_, displayimage_, colorcube, dmask); /* End of XIL Molecule */ } if (visual == TRUECOLOR) { ycc = xil_colorspace_get_by_name(xil_, "ycc601"); rgb = xil_colorspace_get_by_name(xil_, "rgb709"); /* for H261, XIL may drop core on the last frame * to avoid this, only continue as long as 2 or * more frames in the CIS */ /* Begin XIL molecule */ xil_set_attribute(displayimage_,"HW_DECOMPRESS_CIS",(void *)-1); xil_decompress(cis_, imageYCC); if ((targetw_ == lastcisw) && (targeth_ == lastcish)) { xil_set_colorspace(imageYCC, ycc); xil_set_colorspace(displayimage_, rgb); xil_color_convert(imageYCC, displayimage_); } else { xil_set_colorspace(imageYCC, ycc); xil_set_colorspace(ximage_, rgb); xil_color_convert(imageYCC, ximage_); xil_scale(ximage_,displayimage_,"nearest",(1.0*targetw_)/lastcisw,(1.0*targeth_)/lastcish); } /* End of XIL molecule */ } xil_cis_sync(cis_); xil_toss(imageYCC); xil_toss(ximage_); xil_cis_reset(cis_); return (0); }