예제 #1
0
SurfacePtr VaapiEncoderBase::createSurface(VideoEncRawBuffer* inBuffer)
{
    SurfacePtr surface = createSurface();
    if (!surface)
        return surface;

    VaapiImage* image = surface->getDerivedImage();
    if (!image) {
        ERROR("surface->getDerivedImage() failed");
        surface.reset();
        return surface;
    }
    VaapiImageRaw* raw = image->map();
    if (!raw) {
        ERROR("image->map() failed");
        surface.reset();
        return surface;
    }

    assert(inBuffer->size == raw->width * raw->height * 3 / 2);

    uint8_t* src = inBuffer->data;
    uint8_t* dest = raw->pixels[0];
    for (int i = 0; i < raw->height; i++) {
        memcpy(dest, src, raw->width);
        dest += raw->strides[0];
        src += raw->width;
    }
    dest = raw->pixels[1];
    for (int i = 0; i < raw->height/2; i++) {
        memcpy(dest, src, raw->width);
        dest += raw->strides[1];
        src += raw->width;
    }

    return surface;
}
예제 #2
0
void Inter_Bargon::oBargon_intro2(OpGobParams &params) {
	int i;
	int16 mouseX;
	int16 mouseY;
	MouseButtons buttons;
	SurfacePtr surface;
	SoundDesc samples[4];
	int16 comp[5] = { 0, 1, 2, 3, -1 };
	static const char *const sndFiles[] = {"1INTROII.snd", "2INTROII.snd", "1INTRO3.snd", "2INTRO3.snd"};

	surface = _vm->_video->initSurfDesc(320, 200);
	_vm->_video->drawPackedSprite("2ille.ims", *surface);
	_vm->_draw->_frontSurface->blit(*surface, 0, 0, 319, 199, 0, 0);
	_vm->_video->drawPackedSprite("2ille4.ims", *surface);
	_vm->_draw->_frontSurface->blit(*surface, 0, 0, 319, 199, 320, 0);
	_vm->_util->setScrollOffset(320, 0);
	_vm->_video->dirtyRectsAll();
	_vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0);
	_vm->_util->longDelay(1000);
	for (i = 320; i >= 0; i--) {
		_vm->_util->setScrollOffset(i, 0);
		_vm->_video->dirtyRectsAll();
		if ((_vm->_game->checkKeys(&mouseX, &mouseY, &buttons, 0) == kKeyEscape) ||
				_vm->shouldQuit()) {
			_vm->_palAnim->fade(0, -2, 0);
			_vm->_draw->_frontSurface->clear();
			memset((char *)_vm->_draw->_vgaPalette, 0, 768);
			WRITE_VAR(4, buttons);
			WRITE_VAR(0, kKeyEscape);
			WRITE_VAR(57, (uint32) -1);
			break;
		}
	}
	if (!_vm->shouldQuit()) {
		_vm->_util->setScrollOffset(0, 0);
		_vm->_video->dirtyRectsAll();
	}
	surface.reset();
	if (VAR(57) == ((uint32) -1))
		return;

	for (i = 0; i < 4; i++)
		_vm->_sound->sampleLoad(&samples[i], SOUND_SND, sndFiles[i]);
	_vm->_sound->blasterPlayComposition(comp, 0, samples, 4);
	_vm->_sound->blasterWaitEndPlay(true, false);
	_vm->_palAnim->fade(0, 0, 0);
	_vm->_draw->_frontSurface->clear();
}
예제 #3
0
SurfacePtr TempSpriteHandler::createSprite(int16 dataVar, int32 size, int32 offset) {
	SurfacePtr sprt;

	// Sprite requested?
	if (!isSprite(size))
		return sprt;

	// Index sane?
	int index = getIndex(size);
	if ((index < 0) || (index >= Draw::kSpriteCount))
		return sprt;

	// Sprite exists?
	if (!(sprt = _vm->_draw->_spritesArray[index]))
		return sprt;

	if (!create(sprt->getWidth(), sprt->getHeight(), sprt->getBPP() > 1))
		sprt.reset();

	return sprt;
}
예제 #4
0
SurfacePtr VaapiSurface::create(const DisplayPtr& display,
                                VaapiChromaType chromaType,
                                uint32_t width,
                                uint32_t height,
                                void *surfAttribArray,
                                uint32_t surfAttribNum)
{
    VAStatus status;
    uint32_t format, i;
    VASurfaceAttrib *surfAttribs = (VASurfaceAttrib *) surfAttribArray;
    SurfacePtr surface;
    VASurfaceID id;

    assert((surfAttribs && surfAttribNum)
           || (!surfAttribs && !surfAttribNum));


    format = vaapiChromaToVaChroma(chromaType);
    uint32_t externalBufHandle = 0;
    status = vaCreateSurfaces(display->getID(), format, width, height,
                              &id, 1, surfAttribs, surfAttribNum);
    if (!checkVaapiStatus(status, "vaCreateSurfacesWithAttribute()"))
        return surface;

    for (int i = 0; i < surfAttribNum; i++) {
        if (surfAttribs[i].type == VASurfaceAttribExternalBufferDescriptor) {
            VASurfaceAttribExternalBuffers *surfAttribExtBuf
                =
                (VASurfaceAttribExternalBuffers *) surfAttribs[i].value.
                value.p;
            externalBufHandle = surfAttribExtBuf->buffers[0];
            break;
        }
    }
    surface.reset(new VaapiSurface(display, id, chromaType,
                                    width, height,externalBufHandle));
    return surface;
}
예제 #5
0
SurfacePtr VaapiDecSurfacePool::acquireWithWait()
{
    SurfacePtr surface;
    AutoLock lock(m_lock);
    if (m_flushing) {
        ERROR("uppper layer bug, only support flush in decode thread");
        return surface;
    }
    while (m_freed.empty())
        m_cond.wait();

    if (m_flushing) {
        ERROR("uppper layer bug, only support flush in decode thread");
        return surface;
    }

    assert(!m_freed.empty());
    VASurfaceID id = m_freed.front();
    m_freed.pop_front();
    m_allocated[id] = SURFACE_DECODING;
    VaapiSurface* s = m_surfaceMap[id];
    surface.reset(s, SurfaceRecycler(shared_from_this()));
    return surface;
}