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

📄 ovl2_video_render.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
字号:
/*
//
//                  INTEL CORPORATION PROPRIETARY INFORMATION
//     This software is supplied under the terms of a license agreement or
//     nondisclosure agreement with Intel Corporation and may not be copied
//     or disclosed except in accordance with the terms of that agreement.
//       Copyright(c) 2003-2006 Intel Corporation. All Rights Reserved.
//
*/

#if defined(LINUX32) && defined(MT_WILSON)

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "vm_debug.h"
#include "ovl2_video_render.h"
#include "umc_video_data.h"

namespace UMC
{

// Initialize the render, return false if failed, call Close anyway
Status OVL2VideoRender::Init(MediaReceiverParams* pInit)
{
    Status umcRes = UMC_OK;
    VideoRenderParams *pParams = DynamicCast<VideoRenderParams>(pInit);

    if (NULL == pParams)
        umcRes = UMC_ERR_NULL_PTR;

    if (UMC_OK == umcRes)
        umcRes = MobileVideoRender::Init(pInit);

    if (UMC_OK == umcRes)
    {
        m_iDevHandle = open("/dev/fb0", O_RDWR);

        if (0 == m_iDevHandle)
        {
            vm_debug_trace(VM_DEBUG_ALL, "No Frame Buffer device was found or insufficient access rights\n");
            umcRes = UMC_ERR_OPEN_FAILED;
        }
    }

    // Get fixed screen information
    if (UMC_OK == umcRes &&
        0 != ioctl(m_iDevHandle, FBIOGET_FSCREENINFO, &m_sFixInfo))
    {
        vm_debug_trace(VM_DEBUG_ALL, "Error reading fixed information.\n");
        umcRes = UMC_ERR_INIT;
    }

    // Get variable screen information
    if (UMC_OK == umcRes &&
        0 != ioctl(m_iDevHandle, FBIOGET_VSCREENINFO, &m_sVarInfo))
    {
        vm_debug_trace(VM_DEBUG_ALL, "Error reading variable information.\n");
        umcRes = UMC_ERR_INIT;
    }

    //  YUV overlay experiments!!!
    if (NULL != m_iDevHandle)
    {
        close(m_iDevHandle);
        m_iDevHandle = 0;
    }

    if (UMC_OK == umcRes)
    {
        m_iDevHandle = open("/dev/fb2", O_RDWR);

        if (0 == m_iDevHandle)
        {
            vm_debug_trace(VM_DEBUG_ALL, "No Frame Buffer 2 device was found or insufficient access rights\n");
            umcRes = UMC_ERR_OPEN_FAILED;
        }
    }

    if (UMC_OK == umcRes)
    {
        Ipp32s iFormat = 3; // YUV422
        Ipp32s iXPos = 0;
        Ipp32s iYPos = 0;
        m_sVarInfo.nonstd = (iFormat << 20) + (iYPos << 10) + (iXPos);
        m_sVarInfo.bits_per_pixel = 16;

        if (0 != ioctl(m_iDevHandle, FBIOPUT_VSCREENINFO, &m_sVarInfo))
        {
            vm_debug_trace(VM_DEBUG_ALL, "Error setting variable information for fb2.\n");
            umcRes = UMC_ERR_INIT;
        }
    }

    // Get variable screen information
    if (UMC_OK == umcRes &&
        0 != ioctl(m_iDevHandle, FBIOGET_VSCREENINFO, &m_sVarInfo))
    {
        vm_debug_trace(VM_DEBUG_ALL, "Error reading variable information.\n");
        umcRes = UMC_ERR_INIT;
    }

    //  End of YUV overlay experiments!!!

    if (UMC_OK == umcRes)
    {
        // Figure out the size of the screen in bytes
        m_uiMapSize = m_sVarInfo.xres *
                      m_sVarInfo.yres *
                      m_sVarInfo.bits_per_pixel / 8;

        // Map the device to memory
        m_pbMap = (Ipp8u*)mmap(0, m_uiMapSize,
                                    PROT_READ | PROT_WRITE, MAP_SHARED,
                                    m_iDevHandle, 0);
        if (MAP_FAILED == m_pbMap)
        {
            vm_debug_trace(VM_DEBUG_ALL, "Error: failed to map framebuffer device to memory.\n");
            umcRes = UMC_ERR_ALLOC;
        }
    }

    if (UMC_OK != umcRes)
        Close();

    return umcRes;

} // Status OVL2VideoRender::Init(MediaReceiverParams* pInit)

Status OVL2VideoRender::LockInputBuffer(MediaData* pInData)
{
    Status umcRes = UMC_OK;
    VideoData* pVideoData = DynamicCast<VideoData>(pInData);

    if (NULL == pVideoData)
        umcRes = UMC_ERR_NULL_PTR;

    if (UMC_OK == umcRes && NULL == m_pbMap)
        umcRes = UMC_ERR_NOT_INITIALIZED;

    if (UMC_OK == umcRes)
    {
        VM_ASSERT(0 != m_uiMapSize);
        while (VM_TIMEOUT == m_ReadySema.Wait(1000))
        {
            if (m_bStopFlag || m_dfFrameTime == -1.0)
            {
                umcRes = UMC_ERR_END_OF_STREAM;
                break;
            }
        }
    }

    if (UMC_OK == umcRes)
    {
        pVideoData->SetDest(m_pbMap + m_sVarInfo.red.offset,
                            m_pbMap + m_sVarInfo.blue.offset,
                            m_pbMap + m_sVarInfo.green.offset);
        pVideoData->SetPitch(m_sVarInfo.red.length / m_sVarInfo.yres,
                             m_sVarInfo.green.length / (m_sVarInfo.yres),
                             m_sVarInfo.blue.length / (m_sVarInfo.yres));
    }
    else
    {
        pVideoData->SetDest(NULL);
        pVideoData->SetPitch(0);
    }
    return umcRes;

} // Status OVL2VideoRender::LockInputBuffer(MediaData* pInData)

} // namespace UMC

#endif // defined(LINUX32) && defined(MT_WILSON)

⌨️ 快捷键说明

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