如题

解决方案 »

  1.   

    i just committed external colorspace api support, and updated vfw.
    vfw will now decode yv12 to rgb,yuyv and the like, useful for anyone
    experimenting with avisynth v2.5.xvid's yv12->rgb (or yv12->yuyv) is noticebly faster than divx5.02.
    e.g. load a yv12 avisynth script into virtualdub_yv12.exe, enable
    directshow acceleration and hit play. i estimate we're ~20% faster.http://mplayerhq.hu/pipermail/mplayer-cvslog/2002-October/011215.html建议你看看这个网站
    http://big5.doom9.org/index.html?/Old_news/june03.htm
      

  2.   

    不过我看了YV12的格式是
    Y0-------Yn
    V0-------Vn
    U0-------Un
    我要找到一个转换方法上面的格式是以行数据还是所有的从上面可以看出是不是YV12数据肯定是3的整数被
      

  3.   

    我看一些资料说32位和24位基本是相同的,只是最后一个alpha不同
    32位可以做透明处理
    还有,我如何知道YV12是24位颜色还是32为颜色呢
      

  4.   

    看看吧,我就是用这个
    void
    yv12_to_rgb24_c(uint8_t * dst,
    int dst_stride,
    uint8_t * y_src,
    uint8_t * u_src,
    uint8_t * v_src,
    int y_stride,
    int uv_stride,
    int width,
    int height)
    {
    const uint32_t dst_dif = 6 * dst_stride - 3 * width;
    int32_t y_dif = 2 * y_stride - width; uint8_t *dst2 = dst + 3 * dst_stride;
    uint8_t *y_src2 = y_src + y_stride;
    uint32_t x, y; if (height < 0) { /* flip image? */
    height = -height;
    y_src += (height - 1) * y_stride;
    y_src2 = y_src - y_stride;
    u_src += (height / 2 - 1) * uv_stride;
    v_src += (height / 2 - 1) * uv_stride;
    y_dif = -width - 2 * y_stride;
    uv_stride = -uv_stride;
    } for (y = height / 2; y; y--) {
    /* process one 2x2 block per iteration */
    for (x = 0; x < (uint32_t) width / 2; x++) {
    int u, v;
    int b_u, g_uv, r_v, rgb_y;
    int r, g, b; u = u_src[x];
    v = v_src[x]; b_u = B_U_tab[u];
    g_uv = G_U_tab[u] + G_V_tab[v];
    r_v = R_V_tab[v]; rgb_y = RGB_Y_tab[*y_src];
    b = (rgb_y + b_u) >> SCALEBITS_OUT;
    g = (rgb_y - g_uv) >> SCALEBITS_OUT;
    r = (rgb_y + r_v) >> SCALEBITS_OUT;
    dst[0] = MAX(0, MIN(255, b));
    dst[1] = MAX(0, MIN(255, g));
    dst[2] = MAX(0, MIN(255, r)); y_src++;
    rgb_y = RGB_Y_tab[*y_src];
    b = (rgb_y + b_u) >> SCALEBITS_OUT;
    g = (rgb_y - g_uv) >> SCALEBITS_OUT;
    r = (rgb_y + r_v) >> SCALEBITS_OUT;
    dst[3] = MAX(0, MIN(255, b));
    dst[4] = MAX(0, MIN(255, g));
    dst[5] = MAX(0, MIN(255, r));
    y_src++; rgb_y = RGB_Y_tab[*y_src2];
    b = (rgb_y + b_u) >> SCALEBITS_OUT;
    g = (rgb_y - g_uv) >> SCALEBITS_OUT;
    r = (rgb_y + r_v) >> SCALEBITS_OUT;
    dst2[0] = MAX(0, MIN(255, b));
    dst2[1] = MAX(0, MIN(255, g));
    dst2[2] = MAX(0, MIN(255, r));
    y_src2++; rgb_y = RGB_Y_tab[*y_src2];
    b = (rgb_y + b_u) >> SCALEBITS_OUT;
    g = (rgb_y - g_uv) >> SCALEBITS_OUT;
    r = (rgb_y + r_v) >> SCALEBITS_OUT;
    dst2[3] = MAX(0, MIN(255, b));
    dst2[4] = MAX(0, MIN(255, g));
    dst2[5] = MAX(0, MIN(255, r));
    y_src2++; dst += 6;
    dst2 += 6;
    } dst += dst_dif;
    dst2 += dst_dif; y_src += y_dif;
    y_src2 += y_dif; u_src += uv_stride;
    v_src += uv_stride;
    }
    }
      

  5.   

    谢谢sexmwj(抱抱我) 
    我如何知道YV12是24位颜色还是32为颜色呢
      

  6.   

    这个要看你的解码器设置了,用DivX和Xvid都可以设置的,资料上都有
      

  7.   

    哈哈,看我的(得到当前颜色位数):         LPDIRECTDRAWSURFACE7 m_pMainSurface;
             int nBit=-1;//颜色位数

    DDPIXELFORMAT DDPixelFormat;
    ZeroMemory(&DDPixelFormat,sizeof(DDPixelFormat));
    DDPixelFormat.dwSize=sizeof(DDPixelFormat);
    DDPixelFormat.dwFlags=DDPF_RGB; if (m_pMainSurface->GetPixelFormat(&DDPixelFormat)==DD_OK)
    {
    nBit=DDPixelFormat.dwRGBBitCount ;
    }
    if(nBit==16)
    {
    //format 555
        if(DDPixelFormat.dwGBitMask==0x000003E0)
    {
    nBit=15;
    }
    }