📄 compo_rect.c
字号:
/*****************************************************************************File name : Compo_rect.cDescription : Compositor rectangle management source fileCOPYRIGHT (C) STMicroelectronics 2000.Date Modification Name---- ------------ ----02 April 2003 Created TM*******************************************************************************//* Private preliminary definitions (internal use only) ---------------------- *//* Includes ----------------------------------------------------------------- */#include <string.h>#include <stdio.h>#include "stddefs.h"#include "compo.h"#include "compo_rect.h"#include "halc_rect.h"#ifdef COMPO_BLITTER_BENCHMARK#include "bench_utils.h"#endif/* Private Types ------------------------------------------------------------ */typedef struct{ U32 Width; U32 Height; U32 HNbPass; U32 VNbPass;} PassParams_t;/* Private Constants -------------------------------------------------------- */#if defined(COMPO_ENABLE_GEN_STATICS_TRACE) || defined(COMPO_ENABLE_BASIC_TRACE)#if defined (ST_5100)#define COMPO_NBR_TICKS_PER_MICRO_SECOND 0.015625#elif defined (ST_5105) || defined (ST_5188) || defined (ST_5107) || defined (ST_5162)#define COMPO_NBR_TICKS_PER_MICRO_SECOND 6.250000#elif defined (ST_5301)#define COMPO_NBR_TICKS_PER_MICRO_SECOND 1.002345#endif#endif/* Private Variables (static)------------------------------------------------ *//* Global Variables --------------------------------------------------------- *//* Exported Variables ------------------------------------------------------- */extern char* ColorType[];extern char* BitmapType[];/* Private Macros ----------------------------------------------------------- *//* Private Function prototypes ---------------------------------------------- */static ST_ErrorCode_t stcompo_UpdateScreenCompositionField(STCOMPO_Handle_t CompoHandle, BOOL IsTopField);/* Functions ---------------------------------------------------------------- *//*******************************************************************************Name : CheckForRecurrentCompositionVpsDescription : Test whether the ScreenRect_p contains at least one Recurrent composition viewportParameters :Assumptions :Limitations :Returns :*******************************************************************************/static BOOL CheckForRecurrentCompositionVps(stcompo_ScreenRect_t* ScreenRect_p, stcompo_Overlay_t* BackgroundOverlay_p){ U32 i=0; BOOL ContainsRecurrentCompositionVps = FALSE; halcompo_Overlay_t * HalOverlay_p; do { HalOverlay_p = (halcompo_Overlay_t*)(((stcompo_Overlay_t*)ScreenRect_p->Overlays[i])->HalOverlay); if ((ScreenRect_p->Overlay_pp[i] != BackgroundOverlay_p) && (HalOverlay_p->ReadParams.CompositionRecurrence == STCOMPO_COMPOSITION_RECURRENCE_EVERY_VSYNC)) { ContainsRecurrentCompositionVps = TRUE; } i++; } while((!ContainsRecurrentCompositionVps) && (i<ScreenRect_p->Complexity)); return ContainsRecurrentCompositionVps;}/*******************************************************************************Name : DumpScreenRectListDescription : Display all screen rectangle listParameters :Assumptions :Limitations :Returns :*******************************************************************************/static ST_ErrorCode_t DumpScreenRectList(stcompo_Device_t* Device_p){ FILE* fstream; /* File Handle for write operation */ stcompo_ScreenRect_t* Next_p; U32 i=0, j=0; halcompo_Overlay_t * HalOverlay_p; /* Open stream */ fstream = fopen("COMPO_DUMP_LIST_RECT.txt", "wb"); if ( fstream == NULL ) { return ST_ERROR_BAD_PARAMETER; } /* Recording data */ fprintf(fstream,"---------------------------------------- \n"); fprintf(fstream,"DUMP LIST RECTANGLES\n"); fprintf(fstream,"---------------------------------------- \n"); /* Overwrite support*/ for (Next_p = Device_p->FirstScreenRect_p; Next_p != Device_p->NextScreenRect_p; Next_p = Next_p->NextRect_p) { fprintf(fstream,"\nRectangle %d\n",i); fprintf(fstream,"=========================== \n"); fprintf(fstream,"PositionX = %d\n", Next_p->Rect.PositionX); fprintf(fstream,"PositionY = %d\n", Next_p->Rect.PositionY); fprintf(fstream,"Width = %d\n", Next_p->Rect.Width); fprintf(fstream,"Height = %d\n", Next_p->Rect.Height); fprintf(fstream,"Complexity = %d\n", Next_p->Complexity); fprintf(fstream,"TileWidth = %d\n", Next_p->TileWidth); fprintf(fstream,"TileHeight = %d\n", Next_p->TileHeight); fprintf(fstream,"Contain Video = %d\n", Next_p->ContainVideo); fprintf(fstream,"Source Slice Number = %d\n", Next_p->SrcSliceNbr); for ( j=0 ; j<Next_p->Complexity ; j++ ) { HalOverlay_p = (halcompo_Overlay_t*)(((stcompo_Overlay_t*)Next_p->Overlays[j])->HalOverlay); fprintf(fstream,"\n\tViewport %d\n",j); fprintf(fstream,"\t--------------------------- \n"); fprintf(fstream,"\t\tIs Background = %s\n", ( Next_p->Overlay_pp[j] == &(Device_p->BackgroundOverlay ) ? "Yes" : "No" ) ); fprintf(fstream,"\t\tFlags : %d\n",HalOverlay_p->ReadParams.Flags); fprintf(fstream,"\t\tColorType : %s\n",ColorType[HalOverlay_p->ReadParams.Bitmap1_p->ColorType]); fprintf(fstream,"\t\tBitmapType : %s\n",BitmapType[HalOverlay_p->ReadParams.Bitmap1_p->BitmapType]); fprintf(fstream,"\t\tAlpha : %d\n",HalOverlay_p->ReadParams.ConstantAlpha); fprintf(fstream,"\t\tSource : X=%d Y=%d W=%d H=%d\n",HalOverlay_p->ReadParams.IORect1_p->SrcRect.PositionX, HalOverlay_p->ReadParams.IORect1_p->SrcRect.PositionY, HalOverlay_p->ReadParams.IORect1_p->SrcRect.Width, HalOverlay_p->ReadParams.IORect1_p->SrcRect.Height); fprintf(fstream,"\t\tDestination : X=%d Y=%d W=%d H=%d\n",HalOverlay_p->ReadParams.IORect1_p->DstRect.PositionX, HalOverlay_p->ReadParams.IORect1_p->DstRect.PositionY, HalOverlay_p->ReadParams.IORect1_p->DstRect.Width, HalOverlay_p->ReadParams.IORect1_p->DstRect.Height); fprintf(fstream,"\t\tHalCompositionRecurrence : %d\n",HalOverlay_p->ReadParams.CompositionRecurrence); fprintf(fstream,"\t\tHalPerformComposition : %d\n",HalOverlay_p->ReadParams.PerformComposition); } i++; } /* Close stream */ fclose (fstream); return (ST_NO_ERROR);}/*******************************************************************************Name : ScreenRectReallocDescription :Parameters :Assumptions :Limitations :Returns :*******************************************************************************/void ScreenRectsReallocation(stcompo_Device_t* Device_p){ /* Screen Rect list reallocation if no more element available */ if (Device_p->NextScreenRect_p == Device_p->LastScreenRect_p) { stcompo_ScreenRect_t* Next_p; U32 Last; /* Convert pointers to offsets for realloc */ Last = Device_p->LastScreenRect_p - Device_p->FirstScreenRect_p; Device_p->FirstScreenRect_p = (stcompo_ScreenRect_t *) realloc(Device_p->FirstScreenRect_p, (Last + DEFAULT_SCREENRECTS) * sizeof(stcompo_ScreenRect_t)); /* Convert offsets back into pointers */ Device_p->LastScreenRect_p = Device_p->FirstScreenRect_p + Last + DEFAULT_SCREENRECTS; Device_p->NextScreenRect_p = Device_p->FirstScreenRect_p + Last; /* Initialized Overlay_pp because all screen rect address have changed */ for (Next_p = Device_p->FirstScreenRect_p; Next_p != Device_p->LastScreenRect_p; Next_p++) { Next_p->Overlay_pp = Next_p->Overlays; } }}/*******************************************************************************Name : DecomposeRectangleDescription : Check if overlay interested in this rectangle is Video.Parameters :Assumptions :Limitations :Returns : TRUE if rectangle containing video overlay*******************************************************************************/void DecomposeScreenRect(stcompo_Device_t* Device_p, stcompo_ScreenRect_t* ScreenRect_p){ U32 OverlayNbr = 0; /* The Number of the rectangle overlay to be checked if it conatins video */ U32 HeightMod = (Device_p->ReadParams.ScreenHeight%(SLICES_NUMBER * 16) > 0 ? 1 : 0); U32 SliceHeight = ((Device_p->ReadParams.ScreenHeight/(SLICES_NUMBER * 16)) + HeightMod) * 16; /* Check if sreen rect overlays contain video */ while((OverlayNbr < ScreenRect_p->Complexity) && (!ScreenRect_p->ContainVideo)) { if(HALCOMPO_IsOverlayContainingVideo(ScreenRect_p->Overlay_pp[OverlayNbr]->HalOverlay)) { /* The rectangle contains video overlay so it should be decomposed */ ScreenRect_p->ContainVideo = TRUE; } else { /* Check the next Overlay */ OverlayNbr++; } } /* Only Video Rectangle is decomposed in rectangles: the height of each one is inferior than one Source Slice height and reflects only one source slice */ if(ScreenRect_p->ContainVideo && !ScreenRect_p->Decomposed) { U32 VideoOverlayOutputPosY = 0; /* Video Overlay Ouput PositionY */ U32 VideoOverlayInputPosY = 0; /* Video Overlay Input PositionY */ U32 FirstSliceNbr = 0; /* Displayed video source first slice number */ U32 FirstSrcSliceHeight = 0; /* First source slice height */ U32 FirstDstSliceHeight = 0; /* The height of the first target widow slice that reflects first * source slice height */ U32 DstSliceHeight = 0; /* The height of a destination slice height that reflects one * source slice height */ U32 SliceNbr = 0; /* Source slice number */ U32 ScreenRectHeight = 0; /* The height of a target widow screen rect that reflects one * source slice height */ U32 DstHeight = 0; /* Destination height that reflects one source height */ U32 NewScreenRectPosY = ScreenRect_p->Rect.PositionY; /* New screen rectangle PositionY */ stcompo_ScreenRect_t* NextRect_p; /* Temp rect used to link the new rect with the correspondent next rect */ stcompo_ScreenRect_t* PrevRect_p; /* Temp rect used to link the new rect with the correspondent previous rect */ /* Get Video overlay Input and Output PositionY params */ HALCOMPO_GetOverlayIOPosY(ScreenRect_p->Overlay_pp[OverlayNbr]->HalOverlay, &VideoOverlayOutputPosY, &VideoOverlayInputPosY); /* Screen rect decomposed */ ScreenRect_p->Decomposed = TRUE; /* Calculate Fist Slice params */ FirstSliceNbr = (VideoOverlayInputPosY / SliceHeight) + 1; FirstSrcSliceHeight = (FirstSliceNbr * SliceHeight) - VideoOverlayInputPosY; FirstDstSliceHeight = HALCOMPO_GetOverlayRectMaxHeight(ScreenRect_p->Overlay_pp[OverlayNbr]->HalOverlay, FirstSrcSliceHeight); /* Record the screen Rect height */ ScreenRectHeight = ScreenRect_p->Rect.Height; /* WA to avoid a knwon issue in FIELD modes when height is odd: the First Dst Slice Height must be even */ if (((FirstDstSliceHeight % 2) == 1) && (ScreenRectHeight > FirstDstSliceHeight)) { FirstDstSliceHeight += 1; } /* First case: Screen Rect PositionY is equal to Video Overlay Output PositionY */ if(ScreenRect_p->Rect.PositionY == VideoOverlayOutputPosY) { /* Check if the decomposition of the current screen rect is needed */ if(ScreenRectHeight > FirstDstSliceHeight) { /* Update the screen rect params to define the correspondent source slice */ ScreenRect_p->Rect.Height = FirstDstSliceHeight; ScreenRect_p->SrcSliceNbr = FirstSliceNbr; /* Update the PositionY and source slice Nbr of the remaining part of the rect to decomposed */ SliceNbr = FirstSliceNbr + 1; NewScreenRectPosY += FirstDstSliceHeight; } else { ScreenRect_p->SrcSliceNbr = FirstSliceNbr; SliceNbr = FirstSliceNbr + 1; } } /* Second case: Screen Rect PositionY is located between the Video Overlay Output PositionY and the PositionY of the end * of the first destination slice */ if((ScreenRect_p->Rect.PositionY < (VideoOverlayOutputPosY + FirstDstSliceHeight)) && (ScreenRect_p->Rect.PositionY > VideoOverlayOutputPosY)) { /* Calculate the new height of Screen Rect */ DstSliceHeight = FirstDstSliceHeight + VideoOverlayOutputPosY - ScreenRect_p->Rect.PositionY; /* Check if the decomposition of the current screen rect is needed */ if(ScreenRectHeight > DstSliceHeight) { /* Update the screen rect params to define the correspondent source slice */ ScreenRect_p->Rect.Height = DstSliceHeight; ScreenRect_p->SrcSliceNbr = FirstSliceNbr; /* Update the PositionY and source slice Nbr of the remaining part of the rect to decomposed */ SliceNbr = FirstSliceNbr + 1; NewScreenRectPosY += DstSliceHeight; } else { ScreenRect_p->SrcSliceNbr = FirstSliceNbr; SliceNbr = FirstSliceNbr + 1; } } /* Third case: Screen Rect PositionY is located up to the the end of the first destination slice*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -