LibraC 發表於 2005-7-21 23:52:47

[轉貼]大陸HDTV 發燒友自己編寫濾鏡耶! 懂的人看一下! ^O^!

原帖: 我完全看不懂, 呵呵! 哪位幫我解釋一下! ^O^!
http://www.silu.info/read.php?tid=30660&fpage=1&toread=&page=1

-------------------------------------------------------------------------------
前言

Pixel Shader是现代显卡GPU的编程语言,可以用于对屏幕输出图像里的每个象素点进行精确的色彩调整。大型三维游戏里面大量采用了Pixel Shader和它的伙伴,Vertex Shader,用于控制各种复杂的场景。

视频播放通常被认为是2D应用,实际上现在的视频播放已经是部分借助于显卡的3D渲染管线来实现的(VMR7、VMR9等渲染模式),使用Pixel Shader可以对最终输出的视频图像进行进一步修正和增强,达到更佳的画面质量,也更充分的发挥显卡(尤其是高端显卡)被闲置的能力。

背景介绍:HiVi烧友已经开始广泛使用ffdshow里面提供的倍线锐化等后期处理滤镜于播放DVD, 尤其是使用投影仪输出时。这些滤镜能够大幅提升DVD的欣赏品质,达到接近HDTV的效果。但是,同样的方式却不能用于HDTV播放上,原因很简单,因为HDTV的分辨率大大提高,做同样的后期处理,对CPU的要求高了很多,再加上视频解码处理也需要由CPU来负责完成(硬件解码的限制),现有的CPU基本无法胜任这样的工作,导致无法流畅播放。而与此同时,显卡GPU却属于基本闲置状态。

Jeff Hsu 發表於 2005-7-22 03:02:22

很有趣的文章,
建議大家連過去看一看,
吵架的口水,沒有營養的,跳過去就好了.

Peter Caesar 發表於 2005-7-22 05:22:48

進不去, 等得 IE 都掛了!
轉貼來看看吧~

Jeff Hsu 發表於 2005-7-22 05:31:49

遵命,

還是請LibraC 幫我把上傳檔案權限打開來,我再傳整個文件上來.



軟硬件需求

硬件:支持PS1.4或更高的顯卡,N卡為FX5200以上,A卡為8500以上(不含9100). 至於CPU等,不太好說,但絕對不支持低端系統。視頻特效無止境,硬件越高級越好
軟件:DX9.0, 播放軟件需要支持Pixel Shader編程。已知的有Media Player Classic 6.4.8.4 或KMPlayer。但KMPlayer尚有點問題,MPC是目前唯一可用的播放器。

MPC裡面使用Shader的辦法

1.   MPC6.4.8.4播放設置調整,修改渲染器設置。除此以外,你還要把解碼器等濾鏡進行相應調整,在此就不再贅述。試驗一下播放是否正常
2.   啟動MPC裡面的Shader編輯程序

http://www.silu.info/1121963741/Type_jpg/145_26271.jpg

3.   輸入shader程序並保存為你喜歡的名字,注意屏幕下方的提示,必須成功才有用。圖片裡的程序僅為示例
4.   再次播放影片,並使用你剛才輸入的shader程序,看看有什麼效果





<font color="#000066">[這篇文章最後由Jeff hsu在 2005/07/22 02:38:56 AM 編輯]</font>

Jeff Hsu 發表於 2005-7-22 05:33:02

以下?可用的shader程序,???增加


消除1080i的白?,要求ps1.4

sampler s0 : register(s0);
float4 p0 : register(c0);
#define height (p0)

float4 main(float2 tex : TEXCOORD0) : COLOR
{
float h = 1080.0f/1088.0f;
float4 pixel = tex2D(s0,tex);
float4 fill = float4(0,0,0,0);

if(height == 1088 && tex.y >=h )
    pixel = fill;

return pixel;
}


xsharpen??(?化版),适用于?支持ps2.0的?卡,如ATI 9xxx系列卡
可以自行修改strength/threshold的值

sampler2D s0 : register(s0);
float4 p0 : register(c0);
#define width (p0)
#define height (p0)

float luma(float4 color)
{
    float4 lum = {0.21484375, 0.7109375, 0.07421875, 0};
    return dot(color, lum);
}

float4 main(float2 tex : TEXCOORD0) : COLOR0
{
    float strength = 1.0f;   //min 0.0f, max 1.0f
    float threshold = 1.0f;   //min 0.0f, max 1.0f
    float4 pmin, pmax,porg;
    float lmin = 1.0f, lmax = 0.0f,lorg;

    for(int i=-1; i<=1; i++)
    {
      for(int j=-1; j<=1; j++)
      {
            if(i==0||j==0)
            {
                  float4 pcur = tex2D(s0, tex.xy + float2(i/width, j/height));
                  float lcur = luma(pcur);
                  if (lcur < lmin) { lmin = lcur; pmin = pcur; }
                  if (lcur > lmax) { lmax = lcur; pmax = pcur; }
                  if(i==0 && j==0) { porg = pcur;lorg=lcur;}
            }
      }
    }

    if(lorg-lmin > lmax-lorg)
    {
      if(lmax-lorg < threshold)
            return pmax*strength+porg*(1-strength);
      else
            return porg;
    }
    else
    {
      if(lorg-lmin < threshold)
            return pmin*strength+porg*(1-strength);
      else
            return porg;
    }
}

Jeff Hsu 發表於 2005-7-22 05:34:16

xsharpen??(完整版),适用于支持ps3.0的?卡,如NVIDIA 6xxx系列卡. ?于ATI X系列卡等也?也可以用

可以自行修改strength/threshold的值

sampler2D s0 : register(s0);
float4 p0 : register(c0);
#define width (p0)
#define height (p0)

float luma(float4 color)
{
float4 lum = {0.21484375, 0.7109375, 0.07421875, 0};
return dot(color, lum);
}

float4 main(float2 tex : TEXCOORD0) : COLOR0
{

float strength = 1.0f;   //min 0.0f, max 1.0f
float threshold = 1.0f;   //min 0.0f, max 1.0f

float4 pmin, pmax,porg;
float lmin = 1.0f, lmax = 0.0f,lorg;

for(int i=-1; i<=1; i++)
{
    for(int j=-1; j<=1; j++)
    {
            float4 pcur = tex2D(s0, tex.xy + float2(i/width, j/height));
            float lcur = luma(pcur);
            if (lcur < lmin) { lmin = lcur; pmin = pcur; }
            if (lcur > lmax) { lmax = lcur; pmax = pcur; }
            if(i==0 && j==0) { porg = pcur;lorg=lcur;}
    }
}

if(lorg-lmin > lmax-lorg)
{
    if(lmax-lorg < threshold)
      return pmax*strength+porg*(1-strength);
    else
      return porg;
}
else
{
    if(lorg-lmin < threshold)
      return pmin*strength+porg*(1-strength);
    else
      return porg;
}
}


xsharpen??(?照版),适用于?支持ps2.0的?卡
可以自行修改strength/threshold的值。屏幕左半?是原始?像,右半?是?化的?像

sampler2D s0 : register(s0);
float4 p0 : register(c0);
#define width (p0)
#define height (p0)

float luma(float4 color)
{
float4 lum = {0.21484375, 0.7109375, 0.07421875, 0};
return dot(color, lum);
}

float4 main(float2 tex : TEXCOORD0) : COLOR0
{
float strength = 1.0f;   //min 0.0f, max 1.0f
float threshold = 1.0f;   //min 0.0f, max 1.0f
float4 pmin, pmax,porg;
float lmin = 1.0f, lmax = 0.0f,lorg;

for(int i=-1; i<=1; i++)
{
    for(int j=-1; j<=1; j++)
    {
      if(i==0||j==0)
      {
            float4 pcur = tex2D(s0, tex.xy + float2(i/width, j/height));
            float lcur = luma(pcur);
            if (lcur < lmin) { lmin = lcur; pmin = pcur; }
            if (lcur > lmax) { lmax = lcur; pmax = pcur; }
            if(i==0 && j==0) { porg = pcur;lorg=lcur;}
      }
    }
}

if(tex.x < 0.5f)
    return porg;
else
if(lorg-lmin > lmax-lorg)
{
    if(lmax-lorg < threshold)
      return pmax*strength+porg*(1-strength);
    else
      return porg;
}
else
{
    if(lorg-lmin < threshold)
      return pmin*strength+porg*(1-strength);
    else
      return porg;
}
}

Peter Caesar 發表於 2005-7-22 05:41:12

看不懂啦~, Jeff 大大;
Thank you, anyway~

LibraC 發表於 2005-7-22 11:45:59

Jeff老大你應該本來就有上傳權限吧?! ^O^!
我幫你看看喔!

已經幫你加了! ^O^!

懂的人幫忙解釋一下啦! 呵呵!
頁: [1]
查看完整版本: [轉貼]大陸HDTV 發燒友自己編寫濾鏡耶! 懂的人看一下! ^O^!