void MoviePlayer::handleNextFrame() { if (_fd.isOpen() == false) { return; } VirtScreen *pvs = &_vm->virtscr[kMainVirtScreen]; uint8 *dst; decodeFrame(); if (_flags & 2) { uint8 *dstPtr = _vm->getResourceAddress(rtImage, _wizResNum); assert(dstPtr); dst = _vm->findWrappedBlock(MKID_BE('WIZD'), dstPtr, 0, 0); assert(dst); copyFrame(dst, 0, 0); } else if (_flags & 1) { dst = pvs->getBackPixels(0, 0); copyFrame(dst, 0, 0); Common::Rect imageRect(_width, _height); _vm->gdi.copyVirtScreenBuffers(imageRect); } else { dst = pvs->getPixels(0, 0); copyFrame(dst, 0, 0); _vm->markRectAsDirty(kMainVirtScreen, 0, 0, _width, _height); } _frameNum++; if (_frameNum == _framesCount) { close(); } }
void DMDFrame::marqueeScrollY(int scrollBy) { scrollBy = scrollBy % height; if(scrollBy < 0) { // Scroll up DMDFrame frame = subFrame(0, 0, width, -scrollBy); // save topmost movePixels(0, -scrollBy, 0, 0, width, height+scrollBy); // move copyFrame(frame, 0, height+scrollBy); // drop back at bottom edge } else { // Scroll down DMDFrame frame = subFrame(0, height-scrollBy, width, scrollBy); // save bottommost movePixels(0, 0, 0, scrollBy, width, height-scrollBy); // move copyFrame(frame, 0, 0); // drop back at top edge } }
void DMDFrame::marqueeScrollX(int scrollBy) { // Scrolling is basically the same as normal scrolling, but we save/restore the overlapping // area in between to create the marquee effect scrollBy = scrollBy % width; if(scrollBy < 0) { // Scroll left DMDFrame frame = subFrame(0, 0, -scrollBy, height); // save leftmost movePixels(-scrollBy, 0, 0, 0, width + scrollBy, height); // move copyFrame(frame, width+scrollBy, 0); // drop back at right edge } else { // Scroll right DMDFrame frame = subFrame(width-scrollBy, 0, scrollBy, height); // save rightmost movePixels(0, 0, scrollBy, 0, width - scrollBy, height); // move copyFrame(frame, 0, 0); // drop back at left edge } }
// transfer specific frame data to the Surface(ANativeWindow) int copyToSurface(uvc_frame_t *frame, ANativeWindow **window) { // ENTER(); int result = 0; if (LIKELY(*window)) { ANativeWindow_Buffer buffer; if (LIKELY(ANativeWindow_lock(*window, &buffer, NULL) == 0)) { // source = frame data const uint8_t *src = (uint8_t *)frame->data; const int src_w = frame->width * PREVIEW_PIXEL_BYTES; const int src_step = frame->width * PREVIEW_PIXEL_BYTES; // destination = Surface(ANativeWindow) uint8_t *dest = (uint8_t *)buffer.bits; const int dest_w = buffer.width * PREVIEW_PIXEL_BYTES; const int dest_step = buffer.stride * PREVIEW_PIXEL_BYTES; // use lower transfer bytes const int w = src_w < dest_w ? src_w : dest_w; // use lower height const int h = frame->height < buffer.height ? frame->height : buffer.height; // transfer from frame data to the Surface copyFrame(src, dest, w, h, src_step, dest_step); ANativeWindow_unlockAndPost(*window); } else { result = -1; } } else { result = -1; } return result; //RETURN(result, int); }
void Animation::cutFrame() { // copy frame data into copy buffer copyFrame(); // always delete frame from all tracks deleteFrame(0,frame); }
void FlicDecoder::FlicVideoTrack::handleFrame() { uint16 chunkCount = _fileStream->readUint16LE(); // Note: The overridden delay is a 16-bit integer (word), whereas the normal delay is a 32-bit integer (dword) // the frame delay is the FLIC "speed", in milliseconds. uint16 newFrameDelay = _fileStream->readUint16LE(); // "speed", in milliseconds if (newFrameDelay > 0) _frameDelay = newFrameDelay; _fileStream->readUint16LE(); // reserved, always 0 uint16 newWidth = _fileStream->readUint16LE(); uint16 newHeight = _fileStream->readUint16LE(); if ((newWidth != 0) || (newHeight != 0)) { if (newWidth == 0) newWidth = _surface->w; if (newHeight == 0) newHeight = _surface->h; _surface->free(); delete _surface; _surface = new Graphics::Surface(); _surface->create(newWidth, newHeight, Graphics::PixelFormat::createFormatCLUT8()); } // Read subchunks for (uint32 i = 0; i < chunkCount; ++i) { uint32 frameSize = _fileStream->readUint32LE(); uint16 frameType = _fileStream->readUint16LE(); uint8 *data = new uint8[frameSize - 6]; _fileStream->read(data, frameSize - 6); switch (frameType) { case FLI_SETPAL: unpackPalette(data); _dirtyPalette = true; break; case FLI_SS2: decodeDeltaFLC(data); break; case FLI_BRUN: decodeByteRun(data); break; case FLI_COPY: copyFrame(data); break; case PSTAMP: /* PSTAMP - skip for now */ break; default: error("FlicDecoder::decodeNextFrame(): unknown subchunk type (type = 0x%02X)", frameType); break; } delete[] data; } }
void CaptureDialog::grabImage() { int thumbWidth = m_width/3 -20; int thumbHeight = (int) thumbWidth*m_aspect; switch(m_state) { case Empty: imgPhase1 = copyFrame(); setPixmap(ui->phase1Thumb,imgPhase1,thumbWidth,thumbHeight); break; case Await1: imgPhase2 = copyFrame(); setPixmap(ui->phase2Thumb,imgPhase2,thumbWidth,thumbHeight); break; case Await2: imgPhase3 = copyFrame(); setPixmap(ui->phase3Thumb,imgPhase3,thumbWidth,thumbHeight); break; } updateState(); }
Frame *callFunc(astNode *root) { Frame *f = loadFrame(copyFrame(root->sym->templt)); //loadFrame(root->sym->templt); //refreshVars(root->sym->code); refreshVars(f->args); // Load up arguments int supplied = 0; astNode *argVars = f->args; for (astNode *arg=root->next; arg != NULL; arg=arg->next) { supplied++; if (argVars == NULL) { fprintf(stderr, "Too many arguments supplied\nOnly wanted %d\n", f->nargs); abort(); } if (arg->op.left->type == STR_nd) { Symbol *s = argVars->op.left->sym; if (s->varType == STRING) free(s->str); s->type = VAR; s->varType = STRING; s->str = arg->op.left->str; } else { Symbol *s = argVars->op.left->sym; s->type = VAR; s->varType = NUMBER; s->val = getValue(arg->op.left); } argVars = argVars->next; } if (argVars != NULL) { fprintf(stderr, "Not enough arguments supplied\nWanted %d, got %d\n", f->nargs, supplied); abort(); } refreshVars(root->sym->code); execute(root->sym->code); f = popFrame(); Frame *top = topFrame(); if (top->next != NULL) { refreshVars(root->sym->code); refreshVars(top->args); } return f; }
struct frameset * copyFrameSet(struct frameset *of) { struct frameset *rf; int n; rf = New(struct frameset); n = of->col * of->row; bcopy((const void *)of, (void *)rf, sizeof(struct frameset)); rf->width = New_N(char *, rf->col); bcopy((const void *)of->width, (void *)rf->width, sizeof(char *) * rf->col); rf->height = New_N(char *, rf->row); bcopy((const void *)of->height, (void *)rf->height, sizeof(char *) * rf->row); rf->frame = New_N(union frameset_element, n); while (n) { n--; if (!of->frame[n].element) goto attr_default; switch (of->frame[n].element->attr) { case F_UNLOADED: case F_BODY: rf->frame[n].body = copyFrame(of->frame[n].body); break; case F_FRAMESET: rf->frame[n].set = copyFrameSet(of->frame[n].set); break; default: attr_default: rf->frame[n].element = NULL; break; } } return rf; }
int main( void ) { help(); // func type int funcType = 1; int processId = 0; // paramater int layerLimit = 3; int widthDeletedDefault = 70; int colorDiffThred = 5; int elePerTagThred = 300; int bandWidthDefault = 50; int keyFrameNumLimit = 30; int badCutLimit = (int)(0.08 * widthDeletedDefault); vector<int> shotArr; switch ( funcType ) { case 0:{ bool state; state = video2Frames( processId ); if ( !state ) return -2; // shot Cut cout << " Shot Cut --ING" << endl; segShotCut( shotArr ); cout << " Convert Process Finished !! " << endl; } case 1:{ int globalTime = clock(); getShotCut( shotArr ); // resize shot for ( int shotId = 1; shotId < (int)shotArr.size(); shotId++ ) { int frameStId = shotArr[shotId - 1]; int frameEdId = shotArr[shotId]; cout << " Process Shot From " << frameStId << " To " << frameEdId << " --ING" << endl << endl; // read frames vector<Mat> frames; bool state; state = readFrameStream( frameStId, frameEdId, frames ); if ( !state ) return -2; // calculate Energy vector<Mat> pixelEnergy; vector<int> pixelTag; int tagNum; calcPixelTag( frames, pixelTag, tagNum, colorDiffThred, elePerTagThred, frameStId ); calcPixelEnergy( frames, pixelTag, tagNum, pixelEnergy, frameStId ); // temporal compress vector<int> keyFrame; timeCompress( pixelEnergy, keyFrame, keyFrameNumLimit ); preserveKeyData( keyFrame, frames, pixelEnergy ); // resize Video int widthDeleted = widthDeletedDefault; vector<Mat> edgeProtect; for ( int c = 0; c < 2; c++ ) { if ( widthDeleted > 0 ) { calcEdgeProtect( frames, edgeProtect ); resizeVideo( keyFrame, frames, pixelEnergy, edgeProtect, layerLimit, widthDeleted, bandWidthDefault, badCutLimit, frameStId, frameEdId, c ); scaleVideo( keyFrame, frames, pixelEnergy, widthDeleted, frameStId, frameEdId, c ); rotateVideo( keyFrame, frames, pixelEnergy, frameStId, frameEdId, c ); } else { copyFrame( frameStId, frameEdId ); } } cout << endl; } // finished cout << " Shot Finished !! Well done !!" << endl; globalTime = clock() - globalTime; globalTime = (globalTime + 500) / 1000; printf( " Global Time Used : %d min %d sec\n", globalTime / 60, globalTime % 60 ); break; } case 2:{ // write frame stream writeFrameStream(); } case 3:{ // write video bool state = writeVideo( processId ); if ( !state ) return -2; break; } default: break; } system( "pause" ); return 0; }
const Graphics::Surface *FlicDecoder::FlicVideoTrack::decodeNextFrame() { // Read chunk uint32 frameSize = _fileStream->readUint32LE(); uint16 frameType = _fileStream->readUint16LE(); uint16 chunkCount = 0; switch (frameType) { case FRAME_TYPE: { chunkCount = _fileStream->readUint16LE(); // Note: The overridden delay is a 16-bit integer (word), whereas the normal delay is a 32-bit integer (dword) // the frame delay is the FLIC "speed", in milliseconds. uint16 newFrameDelay = _fileStream->readUint16LE(); // "speed", in milliseconds if (newFrameDelay > 0) _frameDelay = newFrameDelay; _fileStream->readUint16LE(); // reserved, always 0 uint16 newWidth = _fileStream->readUint16LE(); uint16 newHeight = _fileStream->readUint16LE(); if ((newWidth != 0) && (newHeight != 0)) { if (newWidth == 0) newWidth = _surface->w; if (newHeight == 0) newHeight = _surface->h; _surface->free(); delete _surface; _surface = new Graphics::Surface(); _surface->create(newWidth, newHeight, Graphics::PixelFormat::createFormatCLUT8()); } } break; default: error("FlicDecoder::decodeFrame(): unknown main chunk type (type = 0x%02X)", frameType); break; } // Read subchunks if (frameType == FRAME_TYPE) { for (uint32 i = 0; i < chunkCount; ++i) { frameSize = _fileStream->readUint32LE(); frameType = _fileStream->readUint16LE(); uint8 *data = new uint8[frameSize - 6]; _fileStream->read(data, frameSize - 6); switch (frameType) { case FLI_SETPAL: unpackPalette(data); _dirtyPalette = true; break; case FLI_SS2: decodeDeltaFLC(data); break; case FLI_BRUN: decodeByteRun(data); break; case FLI_COPY: copyFrame(data); break; case PSTAMP: /* PSTAMP - skip for now */ break; default: error("FlicDecoder::decodeNextFrame(): unknown subchunk type (type = 0x%02X)", frameType); break; } delete[] data; } } _curFrame++; _nextFrameStartTime += _frameDelay; if (_atRingFrame) { // If we decoded the ring frame, seek to the second frame _atRingFrame = false; _fileStream->seek(_offsetFrame2); } return _surface; }
int main(int argc, char *argv[]){ if (argc != 1) { printf("USAGE: ./copyFrameTestCUDA\n"); printf(" only works if blobDetection works\n"); return 1; } const char *filename = "frames/diff/frame_1.jpg"; frame_t *frame = (frame_t *)malloc(sizeof(struct frame_s)); if (readImageFrame(frame, filename) == 1) { printf("Unable to read frame at [%s]\n", filename); return 1; } if (blobDetection(frame) == 1) { printf("Unable to detect blobs\n"); return 1; } printf("Copying frame\n"); frame_t *res = copyFrame(frame); if (res == NULL) { printf("Unable to copy frame\n"); return 1; } printf("----Checking all values in frame are the same----\n"); printf("Checking image data is correct\n"); int numBoxes = frame->numBoxes; int i; pixel_t p, pOrig; for (i = 0; i < res->image->width*res->image->height; i++) { p = res->image->data[i]; pOrig = frame->image->data[i]; if ((p.L != pOrig.L) || (p.A != pOrig.A) || (p.B != pOrig.B) || (p.S != pOrig.S) || (p.label != pOrig.label)){ printf("Pixel[%d] not valid\n", i); return 1; } } printf("Checking box data is correct\n"); if (frame->arBoxes == NULL) { printf("No boxes found in array\n"); if (res->arBoxes != NULL) { printf("Boxes not initialized correctly\n"); return 1; } } else { printf("Boxes found in array\n"); box_t *pFbox = frame->arBoxes; box_t *pRbox = res->arBoxes; if (frame->numBoxes != res->numBoxes) { printf("Boxes are not equal in number\n"); return 1; } for (i = 0; i < frame->numBoxes; i++) { box_t *box = &pFbox[i]; box_t *rbox = &pRbox[i]; if (box->startx != rbox->startx) { printf("box %d startx not initialized correctly\n", i); //return 1; } if (box->starty != rbox->starty) { printf("box %d starty not initialized correctly\n", i); //return 1; } if (box->centroid_x != rbox->centroid_x) { printf("box %d centroid_x not initialized correctly (original, copied) -> (%d, %d)\n", i, box->centroid_x, rbox->centroid_x); //return 1; } if (box->centroid_y != rbox->centroid_y) { printf("box %d centroid_y not initialized correctly\n", i); ///return 1; } if (box->center_x != rbox->center_x) { printf("box %d center_x not initialized correctly\n", i); //return 1; } if (box->center_y != rbox->center_y) { printf("box %d center_y not initialized correctly\n", i); //return 1; } if (box->height != rbox->height) { printf("box %d height not initialized correctly\n", i); //return 1; } if (box->width != rbox->width) { printf("box %d width not initialized correctly\n", i); //return 1; } if (box->dir != rbox->dir) { printf("box %d dir not initialized correctly\n", i); //return 1; } if (box->tag != rbox->tag) { printf("box %d tag not initialized correctly\n", i); //return 1; } if (box->isValid != rbox->isValid) { printf("box %d isValid not initialized correctly\n", i); //return 1; } } } printf("Box and Image data are correct\n"); printf("----Freeing frame----\n"); if (freeFrame(frame) == 1) { printf("Unable to free frame\n"); return 1; } printf("Checking if new frame exists after free\n"); if (res == NULL) { printf("Frame disappeared after free\n"); return 1; } printf("Checking if boxes exist after free\n"); box_t *rArBox = res->arBoxes; if ((res->numBoxes == 0) && (rArBox != NULL)) { printf("Box copy failure after free\n"); return 1; } else if (rArBox == NULL) { printf("Box copy failure - res is empty\n"); return 1; } else if (numBoxes != res->numBoxes) { printf("Box copy failure - not same num boxes after free\n"); return 1; } else { int i; box_t Bbox; for (i = 0; i < res->numBoxes; i++) { Bbox = rArBox[i]; } printf("Frames copied correctly\n"); } printf("----Freeing copy frame----\n"); if (freeFrame(res) == 1) { printf("Unable to free frame\n"); return 1; } return 0; }
int main(int argc, char *argv[]){ if (argc < 3) { printf("USAGE: ./fullTest <first_image_filename> <second_image_filename>\n"); return 1; } double startTime = CycleTimer::currentSeconds(); double deltaTime; char *filename1 = argv[1]; char *filename2 = argv[2]; frame_t *frame1 = (frame_t *) malloc(sizeof(struct frame_s)); frame_t *frame2 = (frame_t *) malloc(sizeof(struct frame_s)); frame_t *res1 = (frame_t *) malloc(sizeof(struct frame_s)); frame_t *res2 = (frame_t *) malloc(sizeof(struct frame_s)); frame_t *res3 = (frame_t *) malloc(sizeof(struct frame_s)); frame_t *res4 = (frame_t *) malloc(sizeof(struct frame_s)); readImageFrame(frame1, filename1); readImageFrame(frame2, filename2); res1 = copyFrame(frame1); res2 = copyFrame(frame1); res3 = copyFrame(frame2); res4 = copyFrame(frame2); deltaTime = CycleTimer::currentSeconds() - startTime; printf("CopyFrame finished, elapsed time = %f seconds\n", deltaTime); frameToJPG(frame1, "full1.jpg"); frameToJPG(frame2, "full2.jpg"); startTime = CycleTimer::currentSeconds(); if (frameSubtraction(frame1, frame2, res1) != 0) { printf("Error in frame subtraction\n"); } deltaTime = CycleTimer::currentSeconds() - startTime; printf("FrameSubtraction finished, time = %f seconds\n", deltaTime); frameToJPG(res1, "full3.jpg"); startTime = CycleTimer::currentSeconds(); if (thresholdImage(res1, res2) != 0) { printf("Error in thresholdImage\n"); } deltaTime = CycleTimer::currentSeconds() - startTime; printf("thresholdImage finished, time = %f seconds\n", deltaTime); frameToJPG(res2, "full4.jpg"); startTime = CycleTimer::currentSeconds(); if (blobDetection(res2) != 0) { printf("Error in blob detection\n"); } deltaTime = CycleTimer::currentSeconds() - startTime; printf("BlobDetection Finished, time = %f seconds\n", deltaTime); // res2 = copyFrame(res1); if (drawBoxOnImage(res2, res3) != 0) { printf("Error in draw box on image\n"); exit(1); } printf("Writing frame\n"); frameToJPG(res3, "full5.jpg"); printf("Write to frame complete, please check file = full5.jpg\n"); startTime = CycleTimer::currentSeconds(); // merge boxes if (mergeBoxes(res2) != 0) { printf("Error in mergeBoxes\n"); exit(1); } deltaTime = CycleTimer::currentSeconds() - startTime; printf("mergeBoxes Finished, time = %f seconds\n", deltaTime); if (drawBoxOnImage(res2, res4) != 0) { printf("Error in draw box on image\n"); exit(1); } printf("Writing frame\n"); frameToJPG(res4, "full6.jpg"); printf("Write to frame complete, please check file = full6.jpg\n"); printf("Freeing frames\n"); int err = freeFrame(frame1); err += freeFrame(frame2); err += freeFrame(res1); err += freeFrame(res2); err += freeFrame(res3); err += freeFrame(res4); if (err != 0) { printf("Unable to free frame\n"); return 1; } return 0; }