From 4bba52954fb5d5b9995e53f525818f41fc275837 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sun, 19 Aug 2012 14:26:46 +0200 Subject: [PATCH] Last shader saves --- glmocoshader.cc | 114 ++++++++++++++++++++++++++++++++++-------------- videovpeogl.cc | 15 ++++--- 2 files changed, 89 insertions(+), 40 deletions(-) mode change 100755 => 100644 videovpeogl.cc diff --git a/glmocoshader.cc b/glmocoshader.cc index 11df477..4afd6b9 100755 --- a/glmocoshader.cc +++ b/glmocoshader.cc @@ -272,6 +272,7 @@ const GLchar moco_frag_shader[] = "const float c1over2048=1./2048.;\n" "const float c1over1024=1./1024.;\n" "const float c255=255.;\n" + "const float c1over255=1./255.;\n" "const float c65280=65280.;\n" "const float c65536=65536.;\n" "const float cstep=32767.;\n" @@ -279,7 +280,12 @@ const GLchar moco_frag_shader[] = "float unpack_short(vec2 income) {\n" " float temp=income.y*c65280+income.x*c255;\n" " temp-=step(cstep,temp)*c65536;\n" - " return temp/c255;\n" + " return temp*c1over255;\n" + "}" + "vec2 unpack_short2(vec4 income) {\n" + " vec2 temp=income.yw*c65280+income.xz*c255;\n" + " temp-=step(cstep,temp)*c65536;\n" + " return temp*c1over255;\n" "}" // "uniform sampler2D textureV;\n" // "uniform sampler2D textureY;\n" @@ -318,7 +324,8 @@ const GLchar moco_frag_shader[] = " ypos_temp2.xy=ypos_temp1.xy;\n" " }\n" //now get the intra 8x8 Block coordinates - " vec2 ypos_temp3=floor(mod(out_block_edge*vec2(ctwo,line_step),cone)*acht);\n" + " vec4 ypos_temp3;\n" + " ypos_temp3.xy=floor(mod(out_block_edge*vec2(ctwo,line_step),cone)*acht);\n" " ypos_temp2.x=(ypos_temp3.x+(ypos_temp3.y+acht*(ypos_temp2.x))*acht);\n" //" bool subsample=(mod(ypos_temp2.x,ctwo)>halfst);\n" " bool subsample=mod(ypos_temp3.x,ctwo)==cone;\n" @@ -334,7 +341,7 @@ const GLchar moco_frag_shader[] = " our_fragcol.r=unpack_short(ypos_temp3.xy);\n" //now uv - " ypos_temp3=floor(out_block_edge*acht);\n" + /* " ypos_temp3=floor(out_block_edge*acht);\n" " ypos_temp2.yw=floor(out_uvblockpos_xy.zw);\n" " ypos_temp2.xz=(ypos_temp3.x+(ypos_temp3.y+acht*(out_uvblockpos_xy.xy))*acht);\n" //" subsample=(mod(ypos_temp2.x,ctwo)>halfst);\n" @@ -351,12 +358,41 @@ const GLchar moco_frag_shader[] = " our_fragcol.g=unpack_short(ypos_temp3.xy);\n" " ypos_temp1=texture2D(blocks,ypos_temp2.zw);\n" // now select the right data - //" if (subsample){\n" + " if (subsample){\n" + " ypos_temp3.xy=ypos_temp1.zw;\n" + " }else {\n" + " ypos_temp3.xy=ypos_temp1.xy;\n" + " }\n" + " our_fragcol.b=unpack_short(ypos_temp3.rg);\n"*/ + " ypos_temp3.xy=floor(out_block_edge*acht);\n" + " ypos_temp2.yw=floor(out_uvblockpos_xy.zw);\n" + " ypos_temp2.xz=(ypos_temp3.x+(ypos_temp3.y+acht*(out_uvblockpos_xy.xy))*acht);\n" + //" subsample=(mod(ypos_temp2.x,ctwo)>halfst);\n" + " subsample=mod(ypos_temp3.x,ctwo)==cone;\n" + " ypos_temp2.xz*=halfst;\n" + " ypos_temp2*=c1over1024;\n" + + " ypos_temp1=texture2D(blocks,ypos_temp2.xy);\n" // now select the right data//82 + " ypos_temp3=texture2D(blocks,ypos_temp2.zw);\n" // now select the right data + // " if (subsample){\n" + //" ypos_temp3.zw=ypos_temp3.zw;\n" + //" ypos_temp3.xy=ypos_temp1.zw;\n" + //" ypos_temp3=vec4(ypos_temp1.zw,ypos_temp3.zw);\n" + + // " }else {\n" + " ypos_temp3=vec4(ypos_temp1.xy,ypos_temp3.xy);\n" + // " }\n" + " our_fragcol.gb=unpack_short2(ypos_temp3);\n" + //" our_fragcol.g=unpack_short(ypos_temp3.xy);\n" + //" our_fragcol.b=unpack_short(ypos_temp3.zw);\n" + + + /* " if (subsample){\n" " ypos_temp3.xy=ypos_temp1.zw;\n" - //" }else {\n" + " }else {\n" " ypos_temp3.xy=ypos_temp1.xy;\n" - //" }\n" - " our_fragcol.b=unpack_short(ypos_temp3.rg);\n" + " }\n" + " our_fragcol.b=unpack_short(ypos_temp3.rg);\n"*/ //MOCO // decide if it is top or bottom @@ -367,41 +403,53 @@ const GLchar moco_frag_shader[] = " moco_work=vec4(out_moco_forward.zw,out_moco_backward.zw);\n" "}\n" // now we handle the y fetching - " vec4 moco_temp;\n" - " vec4 subpixel=floor(mod(moco_work,ctwo))*halfst; \n" - " moco_temp=floor(moco_work*halfst)+floor(vec4(out_moco_pos.xy,out_moco_pos.xy));\n" + " vec4 moco_temp1;\n" + " vec4 moco_temp2;\n" + " vec4 subpixel1=floor(mod(moco_work,ctwo))*halfst; \n" + " vec4 subpixel2=floor(mod(moco_work*halfst,ctwo))*halfst; \n" + " moco_temp1=floor(moco_work*halfst)+floor(vec4(out_moco_pos.xy,out_moco_pos.xy));\n" + " moco_temp2=(floor(moco_work*halfst*halfst)+floor(vec4(out_moco_pos.xy,out_moco_pos.xy)*halfst))*ctwo;\n" " vec4 c00,c01,c10,c11;\n" - " c00=texture2D(forward_pic,moco_temp.xy*pict_size);\n" - " c01=texture2D(forward_pic,(moco_temp.xy+vec2(czero,out_misc_info.y))*pict_size);\n" - " c10=texture2D(forward_pic,(moco_temp.xy+vec2(cone,czero))*pict_size);\n" - " c11=texture2D(forward_pic,(moco_temp.xy+vec2(cone,out_misc_info.y))*pict_size);\n" - " our_fragcol.r+=mix(mix(c00.r,c10.r,subpixel.x),mix(c01.r,c11.r,subpixel.x),subpixel.y)*out_moco_pos.z;\n" + " c00.r=texture2D(forward_pic,moco_temp1.xy*pict_size).r;\n" + " c01.r=texture2D(forward_pic,(moco_temp1.xy+vec2(czero,out_misc_info.y))*pict_size).r;\n" + " c10.r=texture2D(forward_pic,(moco_temp1.xy+vec2(cone,czero))*pict_size).r;\n" + " c11.r=texture2D(forward_pic,(moco_temp1.xy+vec2(cone,out_misc_info.y))*pict_size).r;\n" + " c00.gb=texture2D(forward_pic,moco_temp2.xy*pict_size).gb;\n" + " c01.gb=texture2D(forward_pic,(moco_temp2.xy+vec2(czero,ctwo*out_misc_info.y))*pict_size).gb;\n" + " c10.gb=texture2D(forward_pic,(moco_temp2.xy+vec2(ctwo,czero))*pict_size).gb;\n"//106 + " c11.gb=texture2D(forward_pic,(moco_temp2.xy+vec2(ctwo,ctwo*out_misc_info.y))*pict_size).gb;\n" + " vec3 tmp_sub1=vec3(subpixel1.x,subpixel2.xx);" + " vec3 tmp_sub2=vec3(subpixel1.y,subpixel2.yy);" + " our_fragcol.rgb+=mix(mix(c00.rgb,c10.rgb,tmp_sub1),mix(c01.rgb,c11.rgb,tmp_sub1),tmp_sub2)*out_moco_pos.z;\n" + + // " our_fragcol.r+=mix(mix(c00.r,c10.r,subpixel1.x),mix(c01.r,c11.r,subpixel1.x),subpixel1.y)*out_moco_pos.z;\n" + + + // " our_fragcol.gb+=mix(mix(c00.gb,c10.gb,subpixel2.x),mix(c01.gb,c11.gb,subpixel2.x),subpixel2.y)*out_moco_pos.z;\n" + + + " c00.r=texture2D(backward_pic,moco_temp1.zw*pict_size).r;\n"//backward + " c01.r=texture2D(backward_pic,(moco_temp1.zw+vec2(czero,out_misc_info.y))*pict_size).r;\n" + " c10.r=texture2D(backward_pic,(moco_temp1.zw+vec2(cone,czero))*pict_size).r;\n" + " c11.r=texture2D(backward_pic,(moco_temp1.zw+vec2(cone,out_misc_info.y))*pict_size).r;\n" + " c00.gb=texture2D(backward_pic,moco_temp2.zw*pict_size).gb;\n" + " c01.gb=texture2D(backward_pic,(moco_temp2.zw+vec2(czero,ctwo*out_misc_info.y))*pict_size).gb;\n" + " c10.gb=texture2D(backward_pic,(moco_temp2.zw+vec2(ctwo,czero))*pict_size).gb;\n" + " c11.gb=texture2D(backward_pic,(moco_temp2.zw+vec2(ctwo,ctwo*out_misc_info.y))*pict_size).gb;\n" + " tmp_sub1=vec3(subpixel1.z,subpixel2.zz);" + " tmp_sub2=vec3(subpixel1.w,subpixel2.ww);" + " our_fragcol.rgb+=mix(mix(c00.rgb,c10.rgb,tmp_sub1),mix(c01.rgb,c11.rgb,tmp_sub1),tmp_sub2)*out_moco_pos.w;\n" - " c00=texture2D(backward_pic,moco_temp.zw*pict_size);\n"//backward - " c01=texture2D(backward_pic,(moco_temp.zw+vec2(czero,out_misc_info.y))*pict_size);\n" - " c10=texture2D(backward_pic,(moco_temp.zw+vec2(cone,czero))*pict_size);\n" - " c11=texture2D(backward_pic,(moco_temp.zw+vec2(cone,out_misc_info.y))*pict_size);\n" - " our_fragcol.r+=mix(mix(c00.r,c10.r,subpixel.z),mix(c01.r,c11.r,subpixel.z),subpixel.w)*out_moco_pos.w;\n" + //" our_fragcol.r+=mix(mix(c00.r,c10.r,subpixel1.z),mix(c01.r,c11.r,subpixel1.z),subpixel1.w)*out_moco_pos.w;\n" // now handle UV - " subpixel=floor(mod(moco_work*halfst,ctwo))*halfst; \n" - " moco_temp=(floor(moco_work*halfst*halfst)+floor(vec4(out_moco_pos.xy,out_moco_pos.xy)*halfst))*ctwo;\n" - " c00=texture2D(forward_pic,moco_temp.xy*pict_size);\n" - " c01=texture2D(forward_pic,(moco_temp.xy+vec2(czero,ctwo*out_misc_info.y))*pict_size);\n" - " c10=texture2D(forward_pic,(moco_temp.xy+vec2(ctwo,czero))*pict_size);\n" - " c11=texture2D(forward_pic,(moco_temp.xy+vec2(ctwo,ctwo*out_misc_info.y))*pict_size);\n" - " our_fragcol.gb+=mix(mix(c00.gb,c10.gb,subpixel.x),mix(c01.gb,c11.gb,subpixel.x),subpixel.y)*out_moco_pos.z;\n" - " c00=texture2D(backward_pic,moco_temp.zw*pict_size);\n" - " c01=texture2D(backward_pic,(moco_temp.zw+vec2(czero,ctwo*out_misc_info.y))*pict_size);\n" - " c10=texture2D(backward_pic,(moco_temp.zw+vec2(ctwo,czero))*pict_size);\n" - " c11=texture2D(backward_pic,(moco_temp.zw+vec2(ctwo,ctwo*out_misc_info.y))*pict_size);\n" - " our_fragcol.gb+=mix(mix(c00.gb,c10.gb,subpixel.z),mix(c01.gb,c11.gb,subpixel.z),subpixel.w)*out_moco_pos.w;\n" + //" our_fragcol.gb+=mix(mix(c00.gb,c10.gb,subpixel2.z),mix(c01.gb,c11.gb,subpixel2.z),subpixel2.w)*out_moco_pos.w;\n" " gl_FragColor.rgb=our_fragcol.rgb;\n" -// " gl_FragColor.rgb=vec3(our_fragcol.r,halfst,halfst);\n" + // " gl_FragColor.rgb=vec3(our_fragcol.r,halfst,halfst);\n" // " if (out_unsupported==1.) {\n" // " gl_FragColor.gb=vec2(cone,0.0);\n" // "}else if (out_unsupported==2.) {\n" diff --git a/videovpeogl.cc b/videovpeogl.cc old mode 100755 new mode 100644 index 9351e9d..2789ec4 --- a/videovpeogl.cc +++ b/videovpeogl.cc @@ -47,9 +47,9 @@ VideoVPEOGL::VideoVPEOGL() dec_frame_libav_uploading_framebuf=NULL; dec_frame_libav_decoding=NULL; ogl_frame_outside=false; - //decoding_mode=VPE_NO_XVMC; - decoding_mode=VPE_XVMC_MOCOMP; - //decoding_mode=VPE_XVMC_IDCT; + decoding_mode=VPE_NO_XVMC; + //decoding_mode=VPE_XVMC_MOCOMP; +// decoding_mode=VPE_XVMC_IDCT; framebuf_framenum=0; moco_shader=NULL; #endif @@ -375,7 +375,7 @@ void VideoVPEOGL::threadMethod() dec_frame_libav_uploading_int=dec_frame_libav_upload_and_view_pending.front(); dec_frame_libav_uploading_framebuf=(VPE_FrameBuf*)dec_frame_libav_uploading_int->base[0]; - //Log::getInstance()->log("Video", Log::WARN, "threadMethod u and view %d %lld %x",(dec_frame_libav_uploading_framebuf)->pict_num,run, + // Log::getInstance()->log("Video", Log::WARN, "threadMethod u and view %d %lld %x",(dec_frame_libav_uploading_framebuf)->pict_num,run, // dec_frame_libav_uploading_framebuf); // if (dec_frame_libav_upload_only_pending.size()>0) Log::getInstance()->log("Video", Log::WARN, "threadMethod u and view2 %d", // ((VPE_FrameBuf*)dec_frame_libav_upload_only_pending.front())->pict_num); @@ -395,8 +395,8 @@ void VideoVPEOGL::threadMethod() if (!view && dec_frame_libav_upload_only_pending.size()>0) { //this is for uploading reference frames ahead dec_frame_libav_uploading_framebuf=dec_frame_libav_upload_only_pending.front(); - //Log::getInstance()->log("Video", Log::WARN, "threadMethod u %d %lld %x",((VPE_FrameBuf*)dec_frame_libav_uploading_framebuf)->pict_num,run, - // dec_frame_libav_uploading_framebuf); + // Log::getInstance()->log("Video", Log::WARN, "threadMethod u %d %lld %x",((VPE_FrameBuf*)dec_frame_libav_uploading_framebuf)->pict_num,run, + // dec_frame_libav_uploading_framebuf); dec_frame_libav_upload_only_pending.pop_front(); view=false; upload=true; @@ -526,6 +526,7 @@ void VideoVPEOGL::threadMethod() dec_frame_libav_uploading_framebuf->data[2]); } else { //XVMC case + // Log::getInstance()->log("Video", Log::WARN, "XVMC mark1"); xvmc_pix_fmt * pix_fmt=(xvmc_pix_fmt *)dec_frame_libav_uploading_framebuf->data[2]; if (moco_shader && pix_fmt) { @@ -1873,7 +1874,7 @@ int VideoVPEOGL::AllocateCodecsLibav() ogl_frame_mutex.Unlock(); - if (decoding_mode==VPE_XVMC_MOCOMP) { + if (decoding_mode==VPE_XVMC_MOCOMP || decoding_mode==VPE_XVMC_IDCT) { OsdOpenGL* osd=(OsdOpenGL*)osd->getInstance(); osd->BeginPainting(); // get OpenGl context moco_shader=new GLMocoShader(); -- 2.39.5