⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compo_rect.c

📁 COMPO source code for reference
💻 C
📖 第 1 页 / 共 5 页
字号:
        if(ScreenRect_p->Rect.PositionY >= (VideoOverlayOutputPosY + FirstDstSliceHeight))        {            /* Calculate the new height and source slice number of Screen Rect */            DstHeight = HALCOMPO_GetOverlayRectMaxHeight(ScreenRect_p->Overlay_pp[OverlayNbr]->HalOverlay, SliceHeight);            SliceNbr = ((ScreenRect_p->Rect.PositionY - VideoOverlayOutputPosY - FirstDstSliceHeight)/DstHeight)                        + FirstSliceNbr + 1;            DstSliceHeight = (SliceNbr - FirstSliceNbr) * DstHeight + FirstDstSliceHeight - (ScreenRect_p->Rect.PositionY                             - VideoOverlayOutputPosY);            /* 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 = SliceNbr;                /* Update the PositionY and source slice Nbr of the remaining part of the rect to decomposed */                NewScreenRectPosY += DstSliceHeight;                SliceNbr++;            }            else            {                ScreenRect_p->SrcSliceNbr = SliceNbr;                SliceNbr++;            }        }        /* Update Height of the remaining part of the rect to decomposed */        ScreenRectHeight = ScreenRectHeight - ScreenRect_p->Rect.Height;        DstHeight = HALCOMPO_GetOverlayRectMaxHeight(ScreenRect_p->Overlay_pp[OverlayNbr]->HalOverlay, SliceHeight);        /* At this point, the current screen rect params are updated in order to reflect only one determinated source slice.         * The remaining part of the screen rect has to be decomposed on others screen rectangles each of them corresponding         * to only one source slice */        while(ScreenRectHeight > DstHeight)        {            /* Screen Rect list reallocation if no more element available */            ScreenRectsReallocation(Device_p);            /* At this point, NextScreenRect element is available */            /* Update the screen rect params to define the correspondent source slice */            *Device_p->NextScreenRect_p = *ScreenRect_p;            Device_p->NextScreenRect_p->Rect.Height     = DstHeight;            Device_p->NextScreenRect_p->Rect.PositionY  = NewScreenRectPosY;            Device_p->NextScreenRect_p->SrcSliceNbr     = SliceNbr;            /* Update the PositionY, Height and source slice Nbr of the remaining part of the rect to decomposed */            SliceNbr++;            NewScreenRectPosY += DstHeight;            ScreenRectHeight = ScreenRectHeight - DstHeight;            /* Link the new screen Rect with previous and next Rects */            NextRect_p = Device_p->NextScreenRect_p;            PrevRect_p = Device_p->NextScreenRect_p;            if (PrevRect_p != Device_p->FirstScreenRect_p)            {                PrevRect_p--;                Device_p->NextScreenRect_p->PrevRect_p = PrevRect_p;            }            Device_p->NextScreenRect_p++;            NextRect_p->NextRect_p = Device_p->NextScreenRect_p;        }        /* At this point, the remaining part of the rect define only one specified rectangle */        if(ScreenRectHeight > 0)        {            /* Screen Rect list reallocation if no more element available */            ScreenRectsReallocation(Device_p);            /* At this point, NextScreenRect element is available */            /* Update the screen rect params to define the correspondent source slice */            *Device_p->NextScreenRect_p = *ScreenRect_p;            Device_p->NextScreenRect_p->Rect.Height = ScreenRectHeight;            Device_p->NextScreenRect_p->Rect.PositionY = NewScreenRectPosY;            Device_p->NextScreenRect_p->SrcSliceNbr = SliceNbr;            /* Link the new screen Rect with previous and next Rects */            NextRect_p = Device_p->NextScreenRect_p;            PrevRect_p = Device_p->NextScreenRect_p;            if (PrevRect_p != Device_p->FirstScreenRect_p)            {                PrevRect_p--;                Device_p->NextScreenRect_p->PrevRect_p = PrevRect_p;            }            Device_p->NextScreenRect_p++;            NextRect_p->NextRect_p = Device_p->NextScreenRect_p;        }    }}/*******************************************************************************Name        : DecomposeRectangleDescription :Parameters  :Assumptions :Limitations :Returns     :*******************************************************************************/void DecomposeScreenRectangles(stcompo_Device_t*  Device_p){    stcompo_ScreenRect_t* Next_p;    /* Overwrite support */    /* Decompose all rects on screen rects which height is inferior than one Source Slice height and reflects     * only one source slice*/    for (Next_p = Device_p->FirstScreenRect_p; Next_p != Device_p->NextScreenRect_p; Next_p = Next_p->NextRect_p)    {        DecomposeScreenRect(Device_p, Next_p);    }    /* Initialized Overlay_pp because screen rects address have changed */    for (Next_p = Device_p->FirstScreenRect_p; Next_p != Device_p->LastScreenRect_p; Next_p = Next_p++)    {        Next_p->Overlay_pp = Next_p->Overlays;    }}/*******************************************************************************Name        : MoveRectPositionDescription :Parameters  :Assumptions :Limitations :Returns     :*******************************************************************************/void MoveRectPosition(stcompo_Device_t*  Device_p, stcompo_ScreenRect_t* Rect_p, stcompo_ScreenRect_t* Next_p){    /* Check poisition where to move rect_p */    if(Next_p == Device_p->FirstScreenRect_p)    {        /* Cut rect_p links with previous and next rects*/        Rect_p->PrevRect_p->NextRect_p = Rect_p->NextRect_p;        Rect_p->NextRect_p->PrevRect_p = Rect_p->PrevRect_p;        /* Update new rect_p links with previous and next rects */        Next_p->PrevRect_p = Rect_p;        Rect_p->PrevRect_p = NULL;        Rect_p->NextRect_p = Next_p;        /* Move rect_p to first position */        Device_p->FirstScreenRect_p = Rect_p;    }    else    {        /* Cut rect_p links with previous and next rects*/        Rect_p->PrevRect_p->NextRect_p = Rect_p->NextRect_p;        Rect_p->NextRect_p->PrevRect_p = Rect_p->PrevRect_p;        /* Update new rect_p links with previous and next rects */        Next_p->PrevRect_p->NextRect_p = Rect_p;        Rect_p->PrevRect_p = Next_p->PrevRect_p ;        Next_p->PrevRect_p = Rect_p;        Rect_p->NextRect_p = Next_p;    }}/*******************************************************************************Name        : Organize Screen RectanglesDescription : Organize Screen Rectangles to have rects containing video first and              sorted by their PositionYParameters  :Assumptions :Limitations :Returns     :*******************************************************************************/void OrganizeScreenRectangles(stcompo_Device_t*  Device_p){    stcompo_ScreenRect_t* Rect_p;    stcompo_ScreenRect_t* Next_p;    BOOL LoopEnd = FALSE;    /* Overwrite support */    /* Organize Screen Rectangles to have rects containing video first and sorted by their PositionY */    for (Rect_p = Device_p->FirstScreenRect_p->NextRect_p; Rect_p != Device_p->NextScreenRect_p; Rect_p = Rect_p->NextRect_p)    {        /* Check if sreen rect overlays contain video */        if (Rect_p->ContainVideo)        {            Next_p = Device_p->FirstScreenRect_p;            LoopEnd = FALSE;            while((Next_p != Rect_p) && (!LoopEnd))            {                if(!Next_p->ContainVideo)                {                    /* Move screen rect to new Position */                    MoveRectPosition(Device_p, Rect_p, Next_p);                    LoopEnd = TRUE;                }                else                {                    if (Rect_p->Rect.PositionY < Next_p->Rect.PositionY)                    {                        /* Move screen rect to new Position */                        MoveRectPosition(Device_p, Rect_p, Next_p);                        LoopEnd = TRUE;                    }                }                Next_p = Next_p->NextRect_p;           }        }    }}/*******************************************************************************Name        : FreeScreenRectListDescription : Free screen rectangle listParameters  :Assumptions :Limitations :Returns     :*******************************************************************************/static void FreeScreenRectList(stcompo_Device_t*  Device_p){    stcompo_ScreenRect_t* Next_p;    /* Overwrite support */    for (Next_p = Device_p->FirstScreenRect_p; Next_p != Device_p->NextScreenRect_p; Next_p = Next_p->NextRect_p)    {        if (Next_p->Overlay_pp != Next_p->Overlays)        {            free(Next_p->Overlay_pp);            Next_p->Overlay_pp = Next_p->Overlays;        }    }    Device_p->FirstAllocatedScreenRect_p->PrevRect_p = NULL;    Device_p->FirstScreenRect_p = Device_p->FirstAllocatedScreenRect_p;    Device_p->NextScreenRect_p  = Device_p->FirstAllocatedScreenRect_p;}/*******************************************************************************Name        : CommitCompositionDescription : Commit data structures for composition. It copies WriteParams into              ReadParamsParameters  :Assumptions :Limitations :Returns     :*******************************************************************************/static ST_ErrorCode_t CommitComposition(stcompo_Device_t*  Device_p){    ST_ErrorCode_t     Err = ST_NO_ERROR;    stcompo_Overlay_t *Next_p;    stcompo_Overlay_t* OverlayDeleted_p;    STCOMPO_QueueUsed_t QueueUsed;    if ((Device_p->HalComposeScreen) == HALCOMPO_ComposeScreenCQ)    {            QueueUsed = STCOMPO_MAIN;    }    else    {            QueueUsed = STCOMPO_AUX;    }    /* Update all overlays ReadParams with WriteParams */    for (Next_p = Device_p->WriteParams.Front_p; Next_p != NULL; Next_p = (stcompo_Overlay_t *)Next_p->WriteParams.Behind)    {        Next_p->ReadParams = Next_p->WriteParams;    }    /* Update device ReadParams with WriteParams */    Device_p->ReadParams = Device_p->WriteParams;    /* Commit HAL Data structure */#ifndef COMPO_DEBUG_CHECK_ERROR    HALCOMPO_CommitComposition(Device_p->HalCompoHandle, &(Device_p->UpdateComposition), QueueUsed);#else    Err = HALCOMPO_CommitComposition(Device_p->HalCompoHandle, &(Device_p->UpdateComposition), QueueUsed);    if ( Err != ST_NO_ERROR)    {        return Err;    }#endif    /* Delete Overlays which need to */    OverlayDeleted_p = (stcompo_Overlay_t*)Device_p->LastOverlayDeleted;    while (OverlayDeleted_p != NULL)    {        STCOMPO_OverlayHandle_t PreviousDeleted;        PreviousDeleted = OverlayDeleted_p->WriteParams.Behind;#ifndef COMPO_DEBUG_CHECK_ERROR        stcompo_ReleaseElement(&(Device_p->OverlayDataPool),(void*)OverlayDeleted_p);#else        Err = stcompo_ReleaseElement(&(Device_p->OverlayDataPool),(void*)OverlayDeleted_p);        if ( Err != ST_NO_ERROR)        {            return Err;        }#endif        OverlayDeleted_p = (stcompo_Overlay_t*)PreviousDeleted;    }    /* Reset deleted overlay list */    Device_p->LastOverlayDeleted = (STCOMPO_OverlayHandle_t)NULL;#ifdef COMPO_ENABLE_GLOBAL_TRACE    COMPO_TRACE("\r\nCommit");#endif    return Err;}/*******************************************************************************Name        : CreateBaseScreenRectDescription : This function is called whenever the CreateScreenRectList()              function gets to the bottom for a particular rectangle. This will              either be when CreateScreenRectList reaches an opaque overlay or              when there are no overlays left to intersect with.Parameters  :Assumptions :Limitations :Returns     :

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -