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

📄 adi_itu656.c

📁 ADI公司blackfin DSP开发板BF533 EZ-KIT LITE附带的全部原代码
💻 C
📖 第 1 页 / 共 2 页
字号:
        }
        if ((frametype == ADI_ITU656_NTSC_IL) || (frametype == ADI_ITU656_NTSC_PR))
            address1 = address1 + 276;
        else
            address1 = address1 + 288;
    }
    
    // Paints Field2 only when frametype is Interlaced
    if ((frametype == ADI_ITU656_NTSC_IL) || (frametype == ADI_ITU656_PAL_IL))    
    {
        for(i = f2start; i <= f2end; i++)
        {
            // Output YCbCr data (4:2:2 format)
            for(j = 0; j < (widthcount / 2); j++)
            {
                if (j == column_value)      // is this the column to be painted with YCbCr data?
                {                           // Yes, Output YCbCr data (4:2:2 format)
                    *address2++ = *ycbcr_data;
                    *address2++ = *(ycbcr_data+1);
                    *address2++ = *(ycbcr_data+2);
                    *address2++ = *(ycbcr_data+3);
                }
                else
                {                           // No - Paint the column as blank
                    *address2++ = 0x80;
                    *address2++ = 0x10;
                    *address2++ = 0x80;
                    *address2++ = 0x10;
                }
            }           
            if (frametype == ADI_ITU656_NTSC_IL)
            	address2 = address2 + 276;
        	else
            	address2 = address2 + 288;
        }
    }
}

/***************************************************************************** 
**
** Function:            generate_XY
**
** Description:         This function generates the XY preamble value for EAV & SAV 
**
** Arguments:           
**
**  scanline            Current scanline number
**                      
**  frametype           Video frame type
**
**  preambleXY          holds the calculated XY value for EAV / SAV
**
**  videostatus         indicates XY calculation for EAV or SAV
**
** Return value:        None
**                      
**
**
*/

static void generate_XY ( u32 scanline,ADI_ITU656_FRAME_TYPE frametype,u8 *preambleXY,u32 videostatus )
{

    if(frametype == ADI_ITU656_NTSC_IL)        // Frame type is NTSC interlaced 
    {
        if((scanline >= 1) && (scanline <= 3))  // 1-3 Blanking Field 2
        {
            if(videostatus == ADI_ITU656_EAV)  
            {
                *preambleXY = 0xF1;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0xEC;
            }
        }
        else if((scanline >= 4) && (scanline <= 22))    // 4-22 Blanking Field 1
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0xB6;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0xAB;
            }
        }
        else if((scanline >= 23) && (scanline <= 262))  // 23-262 Active Video Field 1
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0x9D;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0x80;
            }
        }
        else if((scanline >= 263) && (scanline <= 265))  // 263-265 Blanking Field 1
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0xB6;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0xAB;
            }
        }
        else if((scanline >= 266) && (scanline <= 285)) // 266-285 Blanking Field 2
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0xF1;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0xEC;
            }
        }
        else if((scanline >= 286) && (scanline <= 525)) // 286-525 Active Video Field 2
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0xDA;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0xC7;
            }
        }
    }
    else if(frametype == ADI_ITU656_PAL_IL)        // Frame type is PAL interlaced
    {
        if((scanline >= 1) && (scanline <= 22)) // 1-22 Blanking Field 1
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0xB6;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0xAB;
            }
        }
        else if((scanline >= 23) && (scanline <= 310))  // 23-310 Active Video Field 1
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0x9D;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0x80;
            }
        }
        else if((scanline >= 311) && (scanline <= 312)) // 311-312 Blanking Field 1
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0xB6;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0xAB;
            }
        }
        else if((scanline >= 313) && (scanline <= 335)) // 313-335 Blanking Field 2
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0xF1;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0xEC;
            }
        }
        else if((scanline >= 336) && (scanline <= 623)) // 336-623 Active Video Field 2
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0xDA;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0xC7;
            }
        }
        else if((scanline >= 624) && (scanline <= 625)) // 624-625 Blanking Field 2
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0xF1;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0xEC;
            }
        }
    }
    else if(frametype == ADI_ITU656_NTSC_PR)       // Frame type is NTSC Progressive   
    {
        if((scanline >= 1) && (scanline <= 45)) // 1-45 Blanking
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0xB6;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0xAB;
            }
        }
        else if((scanline >= 46) && (scanline <= 525))  // 46-525 Active Video
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0x9D;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0x80;
            }
        }
    }
    else if(frametype == ADI_ITU656_PAL_PR)       // Frame type is PAL Progressive   
    {
        if((scanline >= 1) && (scanline <= 44)) // lines 1-44 Blanking
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0xB6;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0xAB;
            }
        }
        else if((scanline >= 45) && (scanline <= 620))  // lines 46-620 Active Video
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0x9D;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0x80;
            }
        }
        else if((scanline >= 621) && (scanline <= 625))  // lines 621-625 Blanking
        {
            if(videostatus == ADI_ITU656_EAV)
            {
                *preambleXY = 0xB6;
            }
            else if(videostatus == ADI_ITU656_SAV)
            {
                *preambleXY = 0xAB;
            }
        }
    }
}

/***************************************************************************** 
**
** Function:            calculate_address
**
** Description:         This function calculates active line address & 
**                      updates widthcount, frame field start and end values
**
** Arguments:           
**
**  frame_ptr           Pointer to the formated video frame in memory
**                      
**  frametype           Frame type of the formated memory
**
**  address1            Holds address of Field 1 first active line's active data start address (for interlaced frame type)
**                      OR First active line's active data start address (for Progressive frame type)
**
**  address2            Holds address of Field 2 first active line's active data start address (for interlaced frame type)
**
**  f1start             Holds Field1 active line start value (for interlaced frameformat) 
**                      OR Active line start value (for progressive frameformat)
**
**  f1end               Holds Field1 active line end value (for interlaced frameformat) 
**                      OR Active line end value (for progressive frameformat)
**
**  f2start             Holds Field2 active line start value (for interlaced frameformat) 
**
**  f2end               Holds Field2 active line end value (for interlaced frameformat) 
**
**  widthcount          Holds the value of NTSC / PAL frame width 
**
** Return value:        None
**                      
**
**/

static void calculate_address ( u8 *frame_ptr,ADI_ITU656_FRAME_TYPE frametype,u8 **address1,u8 **address2,u32 *f1start,
u32 *f1end,u32 *f2start,u32 *f2end,u32 *widthcount)
{

    switch (frametype) {    // Switch to frame type

    // Frame format is NTSC Interlaced
    case (ADI_ITU656_NTSC_IL):

        *widthcount = ADI_ITU656_NTSC_WIDTH;

        *f1start = ADI_ITU656_NTSC_ILF1_START;  // active line start - Field1
        *f1end = ADI_ITU656_NTSC_ILF1_END;      // active line end - Field1
        // Calculate Field 1 first active line's active data start address
        *address1 = frame_ptr + ((ADI_ITU656_NTSC_ILF1_START-1) * 1716) + 276;

        *f2start = ADI_ITU656_NTSC_ILF2_START;  // active line start - Field2
        *f2end = ADI_ITU656_NTSC_ILF2_END;      // active line end - Field2 
        // Calculate Field 2 first active line's active data start address
        *address2 = frame_ptr + ((ADI_ITU656_NTSC_ILF2_START-1) * 1716) + 276;

        break;

    // Frame format is PAL Interlaced
    case (ADI_ITU656_PAL_IL):

        *widthcount = ADI_ITU656_PAL_WIDTH;

        *f1start = ADI_ITU656_PAL_ILF1_START;   // active line start - Field1
        *f1end = ADI_ITU656_PAL_ILF1_END;       // active line end - Field1
        // Calculate Field 1 first active line's active data start address
        *address1 = frame_ptr + ((ADI_ITU656_PAL_ILF1_START-1) * 1728) + 288;

        *f2start = ADI_ITU656_PAL_ILF2_START;   // active line start - Field2
        *f2end = ADI_ITU656_PAL_ILF2_END;       // active line end - Field2
        // Calculate Field 2 first active line's active data start address
        *address2 = frame_ptr + ((ADI_ITU656_PAL_ILF2_START-1) * 1728) + 288;

        break;

    // Frame format is NTSC Progressive
    case (ADI_ITU656_NTSC_PR):

        *widthcount = ADI_ITU656_NTSC_WIDTH;

        *f1start = ADI_ITU656_NTSC_PRF_START;   // active line start
        *f1end = ADI_ITU656_NTSC_PRF_END;       // active line end
        // Calculate First active line's active data start address
        *address1 = frame_ptr + ((ADI_ITU656_NTSC_PRF_START-1)* 1716) + 276;

        break;

    // Frame format is PAL Progressive
    case (ADI_ITU656_PAL_PR):

        *widthcount = ADI_ITU656_PAL_WIDTH;

        *f1start = ADI_ITU656_PAL_PRF_START;   // active line start
        *f1end = ADI_ITU656_PAL_PRF_END;       // active line end
        // Calculate First active line's active data start address
        *address1 = frame_ptr + ((ADI_ITU656_PAL_PRF_START-1)* 1728) + 288;        
        
        break;

    default:    // Default as NTSC Progressive

        *widthcount = ADI_ITU656_NTSC_WIDTH;

        *f1start = ADI_ITU656_NTSC_PRF_START;   // active line start
        *f1end = ADI_ITU656_NTSC_PRF_END;       // active line end
        // Calculate First active line's active data start address
        *address1 = frame_ptr + ((ADI_ITU656_NTSC_PRF_START-1)* 1716) + 276;
        
        break;
    }
}


⌨️ 快捷键说明

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