static int readCompressed(InstanceState *inst, void *buf, int len) { int clen, frames; void *data = NULL; /* Debug Message */ /* PRINT("In readCompressed\n"); */ if (inst == NULL) { return -1; } if (inst->xil_cis == NULL) { return -1; } if (inst->scaled_image) { xil_scale(inst->rtvc_image, inst->scaled_image, "nearest", inst->sx, inst->sy); xil_compress(inst->scaled_image, inst->xil_cis); xil_cis_sync(inst->xil_cis); if (xil_cis_get_write_invalid(inst->xil_cis)) { updateXilCis(inst); return -1; } xil_toss(inst->rtvc_image); xil_toss(inst->scaled_image); } else { xil_compress(inst->rtvc_image, inst->xil_cis); xil_cis_sync(inst->xil_cis); if (xil_cis_get_write_invalid(inst->xil_cis)) { updateXilCis(inst); return -1; } xil_toss(inst->rtvc_image); } if (xil_cis_has_frame(inst->xil_cis)) { data = (void *)xil_cis_get_bits_ptr(inst->xil_cis, &clen, &frames); } if (data) { if (clen > len) { /* Debug Message */ PRINT("readCompressed: buffer too short\n"); clen = -1; } else { memcpy(buf, data, clen); } } else { clen = -1; } return clen; }
static int readRaw(InstanceState *inst, void *buf, int len) { XilImage image; XilMemoryStorage storage; int clen; /* Debug Message */ /* PRINT("In readRaw\n"); */ if (inst == NULL) { return -1; } if (inst->scaled_image) { xil_scale(inst->rtvc_image, inst->scaled_image, "nearest", inst->sx, inst->sy); image = inst->scaled_image; } else { image = inst->rtvc_image; } xil_color_convert(image, inst->colored_image); xil_toss(image); xil_export(inst->colored_image); xil_get_memory_storage(inst->colored_image, &storage); inst->inStrideX = storage.byte.scanline_stride; clen = storage.byte.scanline_stride * inst->outHeight; if (clen > len) { /* Debug Message */ PRINT("readRaw: buffer too short\n"); clen = -1; } else { memcpy(buf, (void *)storage.byte.data, clen); } xil_import(inst->colored_image, 0); xil_toss(inst->colored_image); return clen; }
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); }