コード例 #1
0
Decode_Status
    VaapiDecoderH264::decodePicture(H264NalUnit * nalu,
                                    H264SliceHdr * sliceHdr)
{
    VaapiPictureH264 *picture;
    Decode_Status status;
    H264PPS *const pps = sliceHdr->pps;
    H264SPS *const sps = pps->sequence;

    status = decodeCurrentPicture();
    if (status != DECODE_SUCCESS)
        return status;

    if (m_currentPicture) {
        /* Re-use current picture where the first field was decoded */
        picture = m_currentPicture->newField();
        if (!picture) {
            ERROR("failed to allocate field picture");
            m_currentPicture = NULL;
            return DECODE_FAIL;
        }

    } else {
        /*accquire one surface from m_bufPool in base decoder  */
        picture = new VaapiPictureH264(m_VADisplay,
                                       m_VAContext,
                                       m_bufPool,
                                       VAAPI_PICTURE_STRUCTURE_FRAME);

        VAAPI_PICTURE_FLAG_SET(picture, VAAPI_PICTURE_FLAG_FF);

        /* hack code here */
    }
    m_currentPicture = picture;

    picture->m_pps = pps;

    status = ensureQuantMatrix(picture);
    if (status != DECODE_SUCCESS) {
        ERROR("failed to reset quantizer matrix");
        return status;
    }
    if (!initPicture(picture, sliceHdr, nalu))
        return DECODE_FAIL;
    if (!fillPicture(picture, sliceHdr, nalu))
        return DECODE_FAIL;

    return DECODE_SUCCESS;
}
コード例 #2
0
Decode_Status VaapiDecoderH265::decodeSlice(H265NalUnit *nalu)
{
    SharedPtr<H265SliceHdr> currSlice(new H265SliceHdr(), h265SliceHdrFree);
    H265SliceHdr* slice = currSlice.get();
    H265ParserResult result;
    Decode_Status status;

    memset(slice, 0, sizeof(H265SliceHdr));
    result = h265_parser_parse_slice_hdr(m_parser, nalu, slice);
    if (result == H265_PARSER_ERROR) {
        return DECODE_INVALID_DATA;
    }
    if (result == H265_PARSER_BROKEN_LINK) {
        return DECODE_SUCCESS;
    }
    status = ensureContext(slice->pps->sps);
    if (status != DECODE_SUCCESS) {
        return status;
    }
    if (slice->first_slice_segment_in_pic_flag) {
        status = decodeCurrent();
        if (status != DECODE_SUCCESS)
            return status;
        m_current = createPicture(slice, nalu);
        if (m_noRaslOutputFlag && isRasl(nalu))
            return DECODE_SUCCESS;
        if (!m_current || !m_dpb.init(m_current, slice, nalu, m_newStream))
            return DECODE_INVALID_DATA;
        if (!fillPicture(m_current, slice) || !fillIqMatrix(m_current, slice))
            return DECODE_FAIL;
    }
    if (!m_current)
        return DECODE_FAIL;
    if (!fillSlice(m_current, slice, nalu))
        return DECODE_FAIL;
    if (!slice->dependent_slice_segment_flag)
        std::swap(currSlice, m_prevSlice);
    return status;

}
コード例 #3
0
ファイル: main.c プロジェクト: pigs/Dog_Rescue
int main(void)
{
    while(1)
    {
		previousSpriteState = spriteState;
        pollKeys();
		enableSounds();
		setupInterrupts();


		switch(state)
		{
			case SPLASH:
			{
				REG_DISPCNTL = BG2_ENABLE | MODE3;
				fillPicture((u16 *)splashBitmap);

				if (BUTTON_PRESSED(START_BUTTON))
				{
					state = GAME;
				}
				if (BUTTON_PRESSED(SELECT_BUTTON))
				{
					state = INSTRUCTIONS;
				}
			break;
			}

			case INSTRUCTIONS:
			{
				fillPicture((u16 *)instructionsBitmap);
				if (BUTTON_PRESSED(SELECT_BUTTON))
				{
					state = SPLASH;
				}
				break;
			}
			
			case GAME:
			{

				//load tiles
				DMA_MEMORY[3].source = backgroundTiles;
				DMA_MEMORY[3].destination = &CHARBLOCK[0];
				DMA_MEMORY[3].control = 12000 | DMA_ON;

				//load map
				DMA_MEMORY[3].source = backgroundMap;
				DMA_MEMORY[3].destination = &SCREENBLOCK[27];
				DMA_MEMORY[3].control = 4096 | DMA_ON;

				//load pallette
				DMA_MEMORY[3].source = backgroundPal;
				DMA_MEMORY[3].destination = PAL_MEM;
				DMA_MEMORY[3].control = 256 | DMA_ON;


				//load the sprites into memory
				DMA_MEMORY[3].source = playerTiles;
				DMA_MEMORY[3].destination = &CHARBLOCK[4];
				DMA_MEMORY[3].control = 16384 | DMA_ON;

				DMA_MEMORY[3].source = playerPal;
				DMA_MEMORY[3].destination = SPRITE_PALETTE;
				DMA_MEMORY[3].control = 256 | DMA_ON;
			    
			    
				//Hide all sprites
				int i;
				for(i=0; i<128; i++)
				{
					OAM[i].attr0 |= ATTR0_HIDE;
				}

				//Set Mode 0 BG 0 and Enable sprites. then set up the sprites
				REG_DISPCNTL = MODE0 | BG0_ENABLE | SPRITE_ENABLE;
				REG_BG0CNT = BG_8BPP | BG_REG_64x64 | CBB(0) | SBB(27);

				REG_TM0CNT = 0;
				DMA[1].cnt = 0;

				REG_TM0D   = timerintervalA;       
				REG_TM0CNT = TIMER_ON;

				DMA[1].src = bgsound;
				DMA[1].dst = REG_FIFO_A;
				DMA[1].cnt = DMA_ON | START_ON_FIFO_EMPTY |
							 DMA_32 | DMA_REPEAT |
							 DMA_DESTINATION_FIXED;

				startA = vblankcountA;

				while(1){

					shadowOAM[0].attr0 = (playerRow & MASKROW) | ATTR0_TALL | ATTR0_REGULAR | ATTR0_8BPP;
					shadowOAM[0].attr1 = (playerCol & MASKCOL)| ATTR1_SIZE32;
					shadowOAM[0].attr2 = (SPRITEOFFSET16(0,0));

					shadowOAM[1].attr0 = badguyRow | ATTR0_TALL | ATTR0_REGULAR | ATTR0_8BPP;
					shadowOAM[1].attr1 = badguyCol | ATTR1_SIZE32;
					shadowOAM[1].attr2 = (SPRITEOFFSET16(0,8));

					pollKeys();
					bigRow = playerRow + vOff;
					bigCol = playerCol + hOff;

				switch(spriteState)
				{
					case STILL:
					{
						shadowOAM[0].attr2 = (SPRITEOFFSET16(0,0));
						break;
					}

					case MOVING:
					{
						if((walkCounter%2)==1)
							shadowOAM[0].attr2 = (SPRITEOFFSET16(0,4));
						else if((walkCounter%2==0))
						{
						shadowOAM[0].attr2 = (SPRITEOFFSET16(0,0)); 
						}
						break;
					}

				}	
				

					if(BUTTON_HELD(A_BUTTON) && BUTTON_HELD(B_BUTTON))
					{
						//load tiles
						DMA_MEMORY[3].source = cheatbackgroundTiles;
						DMA_MEMORY[3].destination = &CHARBLOCK[0];
						DMA_MEMORY[3].control = 11456 | DMA_ON;

						//load map
						DMA_MEMORY[3].source = cheatbackgroundMap;
						DMA_MEMORY[3].destination = &SCREENBLOCK[27];
						DMA_MEMORY[3].control = 4096 | DMA_ON;

						//load pallette
						DMA_MEMORY[3].source = cheatbackgroundPal;
						DMA_MEMORY[3].destination = PAL_MEM;
						DMA_MEMORY[3].control = 256 | DMA_ON;
					}
					if (BUTTON_HELD(RIGHT_BUTTON))
					{
						spriteState=MOVING;
						walkCounter++;
						if(collisionmapBitmap[((bigRow+playerHeight)*collMapSize)+(bigCol+playerCVel+playerWidth)]==WHITE)
						{
							if(playerCol<(SCREEN_WIDTH-(playerWidth+5))){
								playerCol+=playerCVel;
							}
							else if(hOff<(collMapSize-SCREEN_WIDTH))
							{
								hOff+=playerCVel;
							}
						}
					}
					if (BUTTON_HELD(LEFT_BUTTON))
					{
						spriteState=MOVING;
						walkCounter++;
						if(collisionmapBitmap[((bigRow+playerHeight)*collMapSize)+(bigCol+playerCVel)]==WHITE)
						{
							if(playerCol>(0))
							{
								playerCol-=playerCVel;
							}
							else if(hOff>(SCREEN_WIDTH-collMapSize))
							{
								hOff-=playerCVel;
							}
						}
					}
					if (BUTTON_HELD(UP_BUTTON))
					{
						spriteState=MOVING;
						walkCounter++;
						//Check collision and move
						if((collisionmapBitmap[(((bigRow-playerRVel)*collMapSize)+(bigCol+playerWidth))]==WHITE)&&
							(collisionmapBitmap[(((bigRow-playerRVel)*collMapSize)+(bigCol))]==WHITE))
						{
							if(playerRow>30)
							{
								playerRow-=playerRVel;
							}
							else if(vOff>0)
							{
								vOff-=playerRVel;
							}
						}
						
					}
					if (BUTTON_HELD(DOWN_BUTTON))
					{
						spriteState=MOVING;
						walkCounter++;
						//Check collision and move
						if((collisionmapBitmap[(((bigRow+playerHeight+playerRVel)*collMapSize)+(bigCol+playerWidth))]==WHITE)&&
							(collisionmapBitmap[(((bigRow+playerHeight+playerRVel)*collMapSize)+(bigCol))]==WHITE))
						{

							if(playerRow<(SCREEN_HEIGHT-(playerHeight)))
							{
								playerRow+=playerRVel;
							}
							else if(vOff<(collMapSize-SCREEN_HEIGHT))
							{
								vOff+=playerRVel;
							}
						if((playerRow > 440) && (playerCol > 464))
						{
							state = WIN;
						}
						}


					}
					if (BUTTON_PRESSED(START_BUTTON))
					{
							REG_TM1CNT = 0;
							DMA[2].cnt = 0;
						
							REG_TM1D   = timerintervalB;       
							REG_TM1CNT = TIMER_ON;

							DMA[2].src = bark;
							DMA[2].dst = REG_FIFO_B;
							DMA[2].cnt = DMA_ON | START_ON_FIFO_EMPTY |
										 DMA_32 | DMA_REPEAT |
										 DMA_DESTINATION_FIXED;

							startB = vblankcountB;
					}
					if (BUTTON_PRESSED(SELECT_BUTTON))
					{
						//waitForNoKey();
						state = PAUSE;
					}
					
					waitForVBlank();
					OAM[0] = shadowOAM[0];
					OAM[1] = shadowOAM[1];

					REG_BG0HOFS = hOff;
					REG_BG0VOFS = vOff;

				}

			}

				case WIN:
				{
					while(1);
				}

				case PAUSE:
				{
					if(BUTTON_PRESSED(SELECT_BUTTON))
					{
						state=GAME;
					}
				}

		}

	}

    return 0;
}