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

📄 ycbcr422pl_to_rgb565_p.sa

📁 基于DM642平台的视频缩小放大功能 程序源代码
💻 SA
📖 第 1 页 / 共 2 页
字号:
* ========================================================================= **   TEXAS INSTRUMENTS, INC.                                                 **                                                                           **   NAME                                                                    **       ycbcr422pl_to_rgb565 -- Planarized YCbCr 4:2:2 to 16-bit RGB 5:6:5  **                               color space conversion.                     **S                                                                          **S  AUTHOR                                                                  **S      Joseph Zbiciak                                                      **S                                                                          **S  REVISION HISTORY                                                        **S      25-Aug-2001 Initial complete version . . . . . . .  J. Zbiciak      **                                                                           **   USAGE                                                                   **       This function is C callable, and is called according to this        **       C prototype:                                                        **                                                                           **       void ycbcr422pl_to_rgb565                                           **       (                                                                   **           const short         coeff[5],  -- Matrix coefficients.          **           const unsigned char *y_data,   -- Luminence data  (Y')          **           const unsigned char *cb_data,  -- Blue color-diff (B'-Y')       **           const unsigned char *cr_data,  -- Red color-diff  (R'-Y')       **           unsigned short      *rgb_data, -- RGB 5:6:5 packed pixel out.   **           unsigned            num_pixels -- # of luma pixels to process.  **       )                                                                   **                                                                           **       The 'coeff[]' array contains the color-space-conversion matrix      **       coefficients.  The 'y_data', 'cb_data' and 'cr_data' pointers       **       point to the separate input image planes.  The 'rgb_data' pointer   **       points to the output image buffer, and must be word aligned.        **                                                                           **       The coefficients in the coeff array must be in signed Q13 form.     **       These coefficients correspond to the following matrix equation:     **                                                                           **           [ coeff[0] 0.0000   coeff[1] ]   [ Y' -  16 ]     [ R']         **           [ coeff[0] coeff[2] coeff[3] ] * [ Cb - 128 ]  =  [ G']         **           [ coeff[0] coeff[4] 0.0000   ]   [ Cr - 128 ]     [ B']         **                                                                           **   DESCRIPTION                                                             **       This kernel performs Y'CbCr to RGB conversion.  From the Color      **       FAQ, http://home.inforamp.net/~poynton/ColorFAQ.html :              **                                                                           **           Various scale factors are applied to (B'-Y') and (R'-Y')        **           for different applications.  The Y'PbPr scale factors are       **           optimized for component analog video.  The Y'CbCr scaling       **           is appropriate for component digital video, JPEG and MPEG.      **           Kodak's PhotoYCC(tm) uses scale factors optimized for the       **           gamut of film colors.  Y'UV scaling is appropriate as an        **           intermediate step in the formation of composite NTSC or PAL     **           video signals, but is not appropriate when the components       **           are keps separate.  Y'UV nomenclature is now used rather        **           loosely, and it sometimes denotes any scaling of (B'-Y')        **           and (R'-Y').  Y'IQ coding is obsolete.                          **                                                                           **       This code can perform various flavors of Y'CbCr to RGB conversion   **       as long as the offsets on Y, Cb, and Cr are -16, -128, and -128,    **       respectively, and the coefficients match the pattern shown.         **                                                                           **       The kernel implements the following matrix form, which involves 5   **       unique coefficients:                                                **                                                                           **           [ coeff[0] 0.0000   coeff[1] ]   [ Y' -  16 ]     [ R']         **           [ coeff[0] coeff[2] coeff[3] ] * [ Cb - 128 ]  =  [ G']         **           [ coeff[0] coeff[4] 0.0000   ]   [ Cr - 128 ]     [ B']         **                                                                           **       Below are some common coefficient sets, along with the matrix       **       equation that they correspond to.   Coefficients are in signed      **       Q13 notation, which gives a suitable balance between precision      **       and range.                                                          **                                                                           **       1.  Y'CbCr -> RGB conversion with RGB levels that correspond to     **           the 219-level range of Y'.  Expected ranges are [16..235] for   **           Y' and [16..240] for Cb and Cr.                                 **                                                                           **           coeff[] = { 0x2000, 0x2BDD, -0x0AC5, -0x1658, 0x3770 };         **                                                                           **           [ 1.0000    0.0000    1.3707 ]   [ Y' -  16 ]     [ R']         **           [ 1.0000   -0.3365   -0.6982 ] * [ Cb - 128 ]  =  [ G']         **           [ 1.0000    1.7324    0.0000 ]   [ Cr - 128 ]     [ B']         **                                                                           **       2.  Y'CbCr -> RGB conversion with the 219-level range of Y'         **           expanded to fill the full RGB dynamic range.  (The matrix has   **           been scaled by 255/219.)  Expected ranges are [16..235] for Y'  **           and [16..240] for Cb and Cr.                                    **                                                                           **           coeff[] = { 0x2543, 0x3313, -0x0C8A, -0x1A04, 0x408D };         **                                                                           **           [ 1.1644    0.0000    1.5960 ]   [ Y' -  16 ]     [ R']         **           [ 1.1644   -0.3918   -0.8130 ] * [ Cb - 128 ]  =  [ G']         **           [ 1.1644    2.0172    0.0000 ]   [ Cr - 128 ]     [ B']         **                                                                           **       Other scalings of the color differences (B'-Y') and (R'-Y')         **       (sometimes incorrectly referred to as U and V) are supported, as    **       long as the color differences are unsigned values centered around   **       128 rather than signed values centered around 0, as noted above.    **                                                                           **       In addition to performing plain color-space conversion, color       **       saturation can be adjusted by scaling coeff[1] through coeff[4].    **       Similarly, brightness can be adjusted by scaling coeff[0].          **       General hue adjustment can not be performed, however, due to the    **       two zeros hard-coded in the matrix.                                 **                                                                           **   TECHNIQUES                                                              **       Pixel replication is performed implicitly on chroma data to         **       reduce the total number of multiplies required.  The chroma         **       portion of the matrix is calculated once for each Cb, Cr pair,      **       and the result is added to both Y' samples.                         **                                                                           **       Matrix Multiplication is performed as a combination of MPY2s and    **       DOTP2s. Saturation to 8bit values is performed using SPACKU4        **       which takes in 4 signed 16-bit values and saturates them to unsigned**       8-bit values. The output of Matrix Multiplication would ideally be  **       in a Q13 format. This however, cannot be fed directly to SPACKU4.   *      *       This implies a shift left by 3 bits, which could be pretty          **       expensive in terms of the number of shifts to be performed. Thus,   **       to avoid being bottlenecked by so many shifts, the Y, Cr & Cb data  **       are shifted left by 3 before multiplication. This is possible       **       because they are 8-bit unsigned data. Due to this, the output of    **       Matrix Multiplication is in a Q16 format, which can be directly fed **       to SPACKU4                                                          **                                                                           **   ASSUMPTIONS                                                             **       The number of luma samples needs to be a multiple of 8 since        **       8 pixels are processed in one cycle of the loop                     *  *                                                                           **   NOTES                                                                   **       n/a.                                                                **                                                                           **   SOURCE                                                                  **      Poynton, Charles et al.  "The Color FAQ,"  1999.                     **          http://home.inforamp.net/~poynton/ColorFAQ.html                  **                                                                           ** ------------------------------------------------------------------------- **             Copyright (c) 2001 Texas Instruments, Incorporated.           **                            All Rights Reserved.                           ** ========================================================================= *                .sect ".text:psa"                .include "ycbcr422pl_to_rgb565_p.h64"_ycbcr422pl_to_rgb565_sa: .cproc  A_coef, B_y_data, A_cb_data, B_cr_data, A_rgb_data, B_num_pix         .reg B_y_7654:B_y_3210,B_cr6420,A_cb6420,B_cr6420_,A_cb6420_,A_y_data         .reg B_y_76_:B_y_54_,A_y_32_:A_y_10_,B_y_76,B_y_54,A_y_32,A_y_10         .reg B_cr64:B_cr20,A_cb64:A_cb20,B_y_7_c0:B_y_6_c0,B_y_5_c0:B_y_4_c0         .reg A_y_3_c0:A_y_2_c0,A_y_1_c0:A_y_0_c0,B_cr6_c1:B_cr4_c1,B_coef         .reg B_cr2_c1:B_cr0_c1,A_cb6_c4:A_cb4_c4,A_cb2_c4:A_cb0_c4         .reg B_cr6cb6,B_cr4cb4,A_cb2cr2,A_cb0cr0,B_cg6,B_cg4,A_cg2,A_cg0         .reg B_r_7,B_r_6,B_r_5,B_r_4,A_r_3,A_r_2,A_r_1,A_r_0,B_g_7         .reg B_g_6,B_g_5,B_g_4,A_g_3,A_g_2,A_g_1,A_g_0,B_b_7,B_b_6         .reg B_b_5,B_b_4,A_b_3,A_b_2,A_b_1,A_b_0,B_r_76,B_r_54,A_r_32           .reg A_r_10,B_g_76,B_g_54,A_g_32,A_g_10,B_b_76,B_b_54,A_b_32         .reg A_b_10,B_r_7654,A_r_3210,B_g_7654,A_g_3210,B_b_7654,A_b_3210         .reg B_r_7654_,B_g_7654_,B_b_7654_,A_r_3210_,A_g_3210_,A_b_3210_         .reg B_r7_r6:B_r5_r4,A_r3_r2:A_r1_r0,B_g7_g6:B_g5_g4,A_g3_g2:A_g1_g0         .reg B_b_7654__,A_b_3210__,B_b7_b6:B_b5_b4,A_b3_b2:A_b1_b0         .reg B_r_b76,B_r_b54,A_r_b32,A_r_b10         ;.reg B_rgb76,B_rgb54,A_rgb32,A_rgb10         .reg B_rgb_ptr,B_loopcnt,B_c0,B_c1,B_g_cb,A_g_cr,B_c3c2,A_c2c3,A_c4         .reg A_k80,A_k08,B_n16,A_msk6,B_msk5,B_k08,B_k01         .reg B_rgb76:B_rgb54,A_rgb32:A_rgb10         .reg A_c0, A_k01         .no_mdep         MV         B_y_data,      A_y_data         MV         A_coef,        B_coef         LDH.D2T2    *B_coef[0],   B_c0              ; luma         PACK2.2     B_c0,         B_c0,      B_c0   ; Packed luma          MV.1x       B_c0,         A_c0         LDH         *B_coef[1],   B_c1              ; r_cr         PACK2       B_c1,         B_c1,      B_c1   ; Packed r_cr         LDH         *B_coef[2],   B_g_cb            ; g_cb          LDH         *A_coef[3],   A_g_cr            ; g_cr

⌨️ 快捷键说明

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