예제 #1
0
void GfxCursor32::move() {
    if (_hideCount) {
        return;
    }

    // Cursor moved onto the screen after being offscreen
    _cursor.rect.moveTo(_position.x - _hotSpot.x, _position.y - _hotSpot.y);
    if (_cursorBack.rect.isEmpty()) {
        revealCursor();
        return;
    }

    // Cursor moved offscreen
    if (!_cursor.rect.intersects(_vmapRegion.rect)) {
        drawToHardware(_cursorBack);
        return;
    }

    if (!_cursor.rect.intersects(_cursorBack.rect)) {
        // Cursor moved to a completely different part of the screen
        _drawBuff1.rect = _cursor.rect;
        _drawBuff1.rect.clip(_vmapRegion.rect);
        readVideo(_drawBuff1);

        _drawBuff2.rect = _drawBuff1.rect;
        copy(_drawBuff2, _drawBuff1);

        paint(_drawBuff1, _cursor);
        drawToHardware(_drawBuff1);

        drawToHardware(_cursorBack);

        _cursorBack.rect = _cursor.rect;
        _cursorBack.rect.clip(_vmapRegion.rect);
        copy(_cursorBack, _drawBuff2);
    } else {
        // Cursor moved, but still overlaps the previous cursor location
        Common::Rect mergedRect(_cursorBack.rect);
        mergedRect.extend(_cursor.rect);
        mergedRect.clip(_vmapRegion.rect);

        _drawBuff2.rect = mergedRect;
        readVideo(_drawBuff2);

        copy(_drawBuff2, _cursorBack);

        _cursorBack.rect = _cursor.rect;
        _cursorBack.rect.clip(_vmapRegion.rect);
        copy(_cursorBack, _drawBuff2);

        paint(_drawBuff2, _cursor);
        drawToHardware(_drawBuff2);
    }
}
예제 #2
0
파일: ts.cpp 프로젝트: atupal/opencv_learn
int main(int argc, char *argv[])
{
	char fileName[255] = "/home/atupal/Downloads/东之伊甸.mp4";
	char tsUnit[][255] = {"opencv_capture", 
							"videoT",
							"videoD",
							"videoB"};

	if (argc > 2) {
		strcpy(fileName, argv[2]);
	}
	if (argc > 1) {
		if (strcmp(argv[1], tsUnit[0]) == 0) {
			readVideo(fileName);
		}
		if (strcmp(argv[1], tsUnit[1]) == 0) {
			readVideoWithATrackbar(fileName);
		}
		if (strcmp(argv[1], tsUnit[2]) == 0) {
			readVideoFromDevice();
		}
		if (strcmp(argv[1], tsUnit[3]) == 0) {
			readVideoForBianhuan(fudiao);
		}
	}

	return 0;
}
예제 #3
0
void GfxCursor32::revealCursor() {
    _cursorBack.rect = _cursor.rect;
    _cursorBack.rect.clip(_vmapRegion.rect);
    if (_cursorBack.rect.isEmpty()) {
        return;
    }

    readVideo(_cursorBack);
    _drawBuff1.rect = _cursor.rect;
    copy(_drawBuff1, _cursorBack);
    paint(_drawBuff1, _cursor);
    drawToHardware(_drawBuff1);
}
예제 #4
0
uint8_t tsHeader::open(const char *name)
{
    char *idxName=(char *)malloc(strlen(name)+6);
    bool r=false;
    FP_TYPE appendType=FP_DONT_APPEND;
    uint32_t append;
    char *type;
    uint64_t startDts;
    uint32_t version=0;

    sprintf(idxName,"%s.idx2",name);
    indexFile index;
    if(!index.open(idxName))
    {
        printf("[tsDemux] Cannot open index file %s\n",idxName);
        free(idxName);
        return false;
    }
    if(!index.readSection("System"))
    {
        printf("[tsDemux] Cannot read system section\n");
        goto abt;
    }
    type=index.getAsString("Type");
    if(!type || type[0]!='T')
    {
        printf("[tsDemux] Incorrect or not found type\n");
        goto abt;
    }

    version=index.getAsUint32("Version");
    if(version!=ADM_INDEX_FILE_VERSION)
    {
        GUI_Error_HIG("Error","This file's index has been created with an older version of avidemux.\nPlease delete the idx2 file and reopen.");
        goto abt;
    }
    append=index.getAsUint32("Append");
    printf("[tsDemux] Append=%"PRIu32"\n",append);
    if(append) appendType=FP_APPEND;
    if(!parser.open(name,&appendType))
    {
        printf("[tsDemux] Cannot open root file (%s)\n",name);
        goto abt;
    }
    if(!readVideo(&index)) 
    {
        printf("[tsDemux] Cannot read Video section of %s\n",idxName);
        goto abt;
    }

    if(!readAudio(&index,name)) 
    {
        printf("[tsDemux] Cannot read Audio section of %s => No audio\n",idxName);
    }

    if(!readIndex(&index))
    {
        printf("[tsDemux] Cannot read index for file %s\n",idxName);
        goto abt;
    }
    updateIdr();
    updatePtsDts();
    _videostream.dwLength= _mainaviheader.dwTotalFrames=ListOfFrames.size();
    printf("[tsDemux] Found %d video frames\n",_videostream.dwLength);
    if(_videostream.dwLength)_isvideopresent=1;
//***********
    
    tsPacket=new tsPacketLinear(videoPid);
    if(tsPacket->open(name,appendType)==false) 
    {
        printf("tsDemux] Cannot tsPacket open the file\n");
        goto abt;
    }
    r=true;
    for(int i=0;i<listOfAudioTracks.size();i++)
    {
        ADM_tsTrackDescriptor *desc=listOfAudioTracks[i];
        ADM_audioStream *audioStream=ADM_audioCreateStream(&desc->header,desc->access);
        if(!audioStream)
        {
            
        }else       
        {
                desc->stream=audioStream;
                audioStream->setLanguage(desc->language);
        }
    }
abt:
    free(idxName);
    index.close();
    printf("[tsDemuxer] Loaded %d\n",r);
    return r;
}
예제 #5
0
uint8_t psHeader::open(const char *name)
{
    char idxName[strlen(name)+4];
    bool r=false;
    FP_TYPE appendType=FP_DONT_APPEND;
    uint32_t append;
    char *type;

    sprintf(idxName,"%s.idx",name);
    indexFile index;
    if(!index.open(idxName))
    {
        printf("[psDemux] Cannot open index file %s\n",idxName);
        return false;
    }
    if(!index.readSection("System"))
    {
        printf("[psDemux] Cannot read system section\n");
        goto abt;
    }
    type=index.getAsString("Type");
    if(!type || type[0]!='P')
    {
        printf("[psDemux] Incorrect or not found type\n");
        goto abt;
    }
    append=index.getAsUint32("Append");

    if(append) appendType=FP_APPEND;
    if(!parser.open(name,&appendType))
    {
        printf("[psDemux] Cannot open root file\n",name);
        goto abt;
    }
    if(!readVideo(&index)) 
    {
        printf("[psDemux] Cannot read Video section of %s\n",idxName);
        goto abt;
    }
    if(!readAudio(&index,name)) 
    {
        printf("[psDemux] Cannot read Audio section of %s\n",idxName);
        goto abt;
    }
    if(!readIndex(&index))
    {
        printf("[psDemux] Cannot read index for file %s\n",idxName);
        goto abt;
    }
    updatePtsDts();
    _videostream.dwLength= _mainaviheader.dwTotalFrames=ListOfFrames.size();
    printf("[psDemux] Found %d video frames\n",_videostream.dwLength);
    if(_videostream.dwLength)_isvideopresent=1;
//***********
    
    psPacket=new psPacketLinear(0xE0);
    if(psPacket->open(name,append)==false) 
    {
        printf("psDemux] Cannot psPacket open the file\n");
        goto abt;
    }
    r=true;
abt:
    index.close();
    printf("[psDemuxer] Loaded %d\n",r);
    return r;
}
예제 #6
0
void GfxCursor32::setView(const GuiResourceId viewId, const int16 loopNo, const int16 celNo) {
    hide();

    _cursorInfo.resourceId = viewId;
    _cursorInfo.loopNo = loopNo;
    _cursorInfo.celNo = celNo;

    if (_macCursorRemap.empty() && viewId != -1) {
        CelObjView view(viewId, loopNo, celNo);

        _hotSpot = view._displace;
        _width = view._width;
        _height = view._height;

        // SSCI never increased the size of cursors, but some of the cursors
        // in early SCI32 games were designed for low-resolution display mode
        // and so are kind of hard to pick out when running in high-resolution
        // mode.
        // To address this, we make some slight adjustments to cursor display
        // in these early games:
        // GK1: All the cursors are increased in size since they all appear to
        //      be designed for low-res display.
        // PQ4: We only make the cursors bigger if they are above a set
        //      threshold size because inventory items usually have a
        //      high-resolution cursor representation.
        bool pixelDouble = false;
        if (g_sci->_gfxFrameout->_isHiRes &&
                (g_sci->getGameId() == GID_GK1 ||
                 (g_sci->getGameId() == GID_PQ4 && _width <= 22 && _height <= 22))) {

            _width *= 2;
            _height *= 2;
            _hotSpot.x *= 2;
            _hotSpot.y *= 2;
            pixelDouble = true;
        }

        _cursor.data = (byte *)realloc(_cursor.data, _width * _height);
        _cursor.rect = Common::Rect(_width, _height);
        memset(_cursor.data, 255, _width * _height);
        _cursor.skipColor = 255;

        Buffer target(_width, _height, _cursor.data);
        if (pixelDouble) {
            view.draw(target, _cursor.rect, Common::Point(0, 0), false, 2, 2);
        } else {
            view.draw(target, _cursor.rect, Common::Point(0, 0), false);
        }
    } else if (!_macCursorRemap.empty() && viewId != -1) {
        // Mac cursor handling
        GuiResourceId viewNum = viewId;

        // Remap cursor view based on what the scripts have given us.
        for (uint32 i = 0; i < _macCursorRemap.size(); i++) {
            if (viewNum == _macCursorRemap[i]) {
                viewNum = (i + 1) * 0x100 + loopNo * 0x10 + celNo;
                break;
            }

            if (i == _macCursorRemap.size())
                error("Unmatched Mac cursor %d", viewNum);
        }

        _cursorInfo.resourceId = viewNum;

        Resource *resource = g_sci->getResMan()->findResource(ResourceId(kResourceTypeCursor, viewNum), false);

        if (!resource) {
            // The cursor resources often don't exist, this is normal behavior
            debug(0, "Mac cursor %d not found", viewNum);
            return;
        }
        Common::MemoryReadStream resStream(resource->data, resource->size);
        Graphics::MacCursor *macCursor = new Graphics::MacCursor();

        if (!macCursor->readFromStream(resStream)) {
            warning("Failed to load Mac cursor %d", viewNum);
            delete macCursor;
            return;
        }

        _hotSpot = Common::Point(macCursor->getHotspotX(), macCursor->getHotspotY());
        _width = macCursor->getWidth();
        _height = macCursor->getHeight();

        _cursor.data = (byte *)realloc(_cursor.data, _width * _height);
        memcpy(_cursor.data, macCursor->getSurface(), _width * _height);
        _cursor.rect = Common::Rect(_width, _height);
        _cursor.skipColor = macCursor->getKeyColor();

        // The cursor will be drawn on next refresh
        delete macCursor;
    } else {
        _hotSpot = Common::Point(0, 0);
        _width = _height = 1;
        _cursor.data = (byte *)realloc(_cursor.data, _width * _height);
        _cursor.rect = Common::Rect(_width, _height);
        *_cursor.data = _cursor.skipColor;
        _cursorBack.rect = _cursor.rect;
        _cursorBack.rect.clip(_vmapRegion.rect);
        if (!_cursorBack.rect.isEmpty()) {
            readVideo(_cursorBack);
        }
    }

    _cursorBack.data = (byte *)realloc(_cursorBack.data, _width * _height);
    _drawBuff1.data = (byte *)realloc(_drawBuff1.data, _width * _height);
    _drawBuff2.data = (byte *)realloc(_drawBuff2.data, _width * _height * 4);
    _savedVmapRegion.data = (byte *)realloc(_savedVmapRegion.data, _width * _height);

    unhide();
}
예제 #7
0
uint8_t psHeader::open(const char *name)
{
    char *idxName=(char *)malloc(strlen(name)+6);
    bool r=false;
    FP_TYPE appendType=FP_DONT_APPEND;
    uint32_t append;
    char *type;
    uint64_t startDts;
    uint32_t version=0;

    sprintf(idxName,"%s.idx2",name);
    indexFile index;
    if(!index.open(idxName))
    {
        printf("[psDemux] Cannot open index file %s\n",idxName);
        free(idxName);
        return false;
    }
    if(!index.readSection("System"))
    {
        printf("[psDemux] Cannot read system section\n");
        goto abt;
    }

    version=index.getAsUint32("Version");
    if(version!=ADM_INDEX_FILE_VERSION)
    {
        GUI_Error_HIG(QT_TRANSLATE_NOOP("psdemuxer","Error"), QT_TRANSLATE_NOOP("psdemuxer","This file's index has been created with an older version of avidemux.\nPlease delete the idx2 file and reopen."));
        goto abt;
    }
    type=index.getAsString("Type");
    if(!type || type[0]!='P')
    {
        printf("[psDemux] Incorrect or not found type\n");
        goto abt;
    }
    append=index.getAsUint32("Append");
    printf("[psDemux] Append=%" PRIu32"\n",append);
    if(append) appendType=FP_APPEND;
    if(!parser.open(name,&appendType))
    {
        printf("[psDemux] Cannot open root file %s\n",name);
        goto abt;
    }
    if(!readVideo(&index)) 
    {
        printf("[psDemux] Cannot read Video section of %s\n",idxName);
        goto abt;
    }
    if(!readAudio(&index,name)) 
    {
        printf("[psDemux] Cannot read Audio section of %s => No audio\n",idxName);
    }
    if(!readIndex(&index))
    {
        printf("[psDemux] Cannot read index for file %s\n",idxName);
        goto abt;
    }
    if(readScrReset(&index))
    {
        ADM_info("Adjusting timestamps\n");
        // Update PTS/DTS of video taking SCR Resets into account
        int nbPoints=listOfScrGap.size();
        int index=0;
        uint64_t pivot=listOfScrGap[0].position;
        uint64_t timeOffset=0;
        uint32_t nbImage=ListOfFrames.size();
        for(int i=0;i<nbImage;i++)
        {
            dmxFrame *frame=ListOfFrames[i];
            if(frame->startAt>pivot) // next gap
            {
                    timeOffset=listOfScrGap[index].timeOffset;
                    index++;
                    if(index>=nbPoints) pivot=0xfffffffffffffffLL;
                        else pivot=listOfScrGap[index].position;
            }
            if(frame->dts!=ADM_NO_PTS) frame->dts+=timeOffset;
            if(frame->pts!=ADM_NO_PTS) frame->pts+=timeOffset;
        }
        ADM_info("Adjusted %d scr reset out of %d\n",(int)index,(int)nbPoints);
        ADM_info("Updating audio with list of SCR\n");
        for(int i=0;i<listOfAudioTracks.size();i++)
                  listOfAudioTracks[i]->access->setScrGapList(&listOfScrGap) ;
    }
    updatePtsDts();
    _videostream.dwLength= _mainaviheader.dwTotalFrames=ListOfFrames.size();
    printf("[psDemux] Found %d video frames\n",_videostream.dwLength);
    if(_videostream.dwLength)_isvideopresent=1;
//***********
    
    psPacket=new psPacketLinear(0xE0);
    if(psPacket->open(name,appendType)==false) 
    {
        printf("psDemux] Cannot psPacket open the file\n");
        goto abt;
    }
    r=true;
    for(int i=0;i<listOfAudioTracks.size();i++)
    {
        ADM_psTrackDescriptor *desc=listOfAudioTracks[i];
        ADM_audioStream *audioStream=ADM_audioCreateStream(&desc->header,desc->access);
        if(!audioStream)
        {
            
        }else       
        {
                desc->stream=audioStream;
        }
    }
abt:
    index.close();
    free(idxName);
    printf("[psDemuxer] Loaded %d\n",r);
    return r;
}