天嵌 ARM开发社区

 找回密码
 注册
查看: 6731|回复: 3

TQ210 linux下NV12T转RGB显示问题

[复制链接]
543872407 发表于 2014-3-12 10:07:41 | 显示全部楼层 |阅读模式
在linux下使用MFC解码出来后的NV12如何使用硬件来RGB格式转换、旋转、缩放显示等功能?网上看了一些帖子是使用android的FIMC的overlay来做的,linux下有相关接口吗
TQ-lkp 发表于 2014-3-12 13:29:00 | 显示全部楼层
  1. memcpy(buf_nv12, output_info.YVirAddr, iBufWidth * iBufHeight);
  2.                 memcpy(&buf_nv12[iBufWidth * iBufHeight], output_info.CVirAddr,
  3.                                 iBufWidth * iBufHeight >> 1);

  4. //                write(fd,buf_nv12,iBufWidth * iBufHeight*3/2);
  5. //                fwrite(buf_nv12, 1, iBufWidth * iBufHeight*3/2, fNv12);
  6. //                printf("write nv12\n");

  7.                 _tile_to_linear_64x32_4x2_neon((unsigned char *) buf_nv12,
  8.                                 (unsigned char *) output_info.YVirAddr, output_info.img_width,
  9.                                 output_info.img_height);

  10.                 _tile_to_linear_64x32_4x2_uv_neon(
  11.                                 (unsigned char *) buf_nv12 + iBufWidth * iBufHeight,
  12.                                 (unsigned char *) output_info.CVirAddr, output_info.img_width,
  13.                                 output_info.img_height >> 1);

  14. //                write(fd_yuv,buf_nv12,iBufWidth * iBufHeight*3/2);
  15. //                fwrite(buf_nv12, 1, iBufWidth * iBufHeight*3/2, fYuv);
  16. //                printf("write yuv\n");

  17.                 ccvt_420p_rgb565(iBufWidth, iBufHeight, buf_nv12,
  18.                                 (unsigned short *) rgb565);
复制代码
这个是从NV12转成rgb565的代码,使用libformat.so,头文件见附件,即可完成转换。




本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
 楼主| 543872407 发表于 2014-3-12 16:18:01 | 显示全部楼层
您好,ccvt_420p_rgb565这个函数在哪呢?要自己实现吗?另外_tile_to_linear_64x32_4x2_neon与 _tile_to_linear_64x32_4x2_uv_neon分别是实现什么样的转换?还有这个转换过程是用软件来转换还是用210里面的FIMC的overlay功能呢。谢谢!
TQ-lkp 发表于 2014-3-12 16:52:26 | 显示全部楼层
在android源码下面找SsbSipMfcDecParser.cpp相关的就是


  1. void ccvt_420p_rgb565(int width, int height, const unsigned char *src,
  2.                 unsigned short *dst) {
  3.         int line, col, linewidth;
  4.         int y, u, v, yy, vr, ug, vg, ub;
  5.         int r, g, b;
  6.         const unsigned char *py, *pu, *pv;

  7.         linewidth = width >> 1;
  8.         py = src;
  9.         pu = py + (width * height);
  10.         pv = pu + (width * height) / 4;

  11.         y = *py++;
  12.         yy = y << 8;
  13.         u = *pu - 128;
  14.         ug = 88 * u;
  15.         ub = 454 * u;
  16.         v = *pv - 128;
  17.         vg = 183 * v;
  18.         vr = 359 * v;

  19.         for (line = 0; line < height; line++) {
  20.                 for (col = 0; col < width; col++) {
  21.                         r = (yy + vr) >> 8;
  22.                         g = (yy - ug - vg) >> 8;
  23.                         b = (yy + ub) >> 8;

  24.                         if (r < 0)
  25.                                 r = 0;
  26.                         if (r > 255)
  27.                                 r = 255;
  28.                         if (g < 0)
  29.                                 g = 0;
  30.                         if (g > 255)
  31.                                 g = 255;
  32.                         if (b < 0)
  33.                                 b = 0;
  34.                         if (b > 255)
  35.                                 b = 255;
  36.                         *dst++ = (((unsigned short) r >> 3) << 11) | (((unsigned short) g
  37.                                         >> 2) << 5) | (((unsigned short) b >> 3) << 0);

  38.                         y = *py++;
  39.                         yy = y << 8;
  40.                         if (col & 1) {
  41.                                 pu++;
  42.                                 pv++;

  43.                                 u = *pu - 128;
  44.                                 ug = 88 * u;
  45.                                 ub = 454 * u;
  46.                                 v = *pv - 128;
  47.                                 vg = 183 * v;
  48.                                 vr = 359 * v;
  49.                         }
  50.                 } /* ..for col */
  51.                 if ((line & 1) == 0) { // even line: rewind
  52.                         pu -= linewidth;
  53.                         pv -= linewidth;
  54.                 }
  55.         } /* ..for line */
  56. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-4-29 03:44 , Processed in 1.046875 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表