Welcome Guest ( Log In | Register )


Important

The forums will be closing permanently the weekend of March 15th. Please see the notice in the announcements forum for details.

 
Filterparam_swap_buffers Breaks Noop-filter, Noob dev seeking help
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
ChrisMedia
  Posted: Jul 6 2011, 11:10 PM


Newbie


Group: Members
Posts: 1
Member No.: 32044
Joined: 6-July 11



Hi,

this is probably a stupid question™, but when I have the following filter code:

CODE

#include <vd2/VDXFrame/VideoFilter.h>

class NoopFilter : public VDXVideoFilter {

public:
 virtual uint32 GetParams();
 virtual void Run();
};

uint32 NoopFilter::GetParams() {
 fa->dst.offset = fa->src.offset;
 return 0;
}

void NoopFilter::Run() {
}

extern VDXFilterDefinition filterDef_invert = VDXVideoFilterDefinition<NoopFilter>("Blah", "Blah", "Blah");


everything is fine and works as it should (does not modify the video), but when I return FILTERPARAM_SWAP_BUFFERS in GetParams(), to start doing something useful in Run(), I get really nasty output artifacts (look "interlacy").


Secondary question/phenomenon: If I write any code in Run(), like inverting the color, the plugin crashes after finishing Run() in ntdll.dll (guess I have been accessing stuff I should not have been accessing?). Here is what I tried for 32-Bit RGB input with FILTERPARAM_SWAP_BUFFERS:

CODE

void InvertFilter::Run() {
 const VDXPixmap& result = *fa->dst.mpPixmap;
 const VDXPixmap& source = *fa->src.mpPixmap;

 sint32 width = source.w;
 sint32 height = source.h;
 uint32* resultdata = (uint32*)result.data;
 uint32* sourcedata = (uint32*)source.data;

 for(sint32 y = 0; y < height; y++)
 {
   for(sint32 x = 0; x < width; x++)
   {
     resultdata[y*width + x] = ~sourcedata[y*width + x];
   }
 }
}

I'm working on Win7 x64, VS2010 (project settings are locked to 32-bit), VirtualDub 1.9.11 32-bit. The SDK sample filters compile and work fine.

Regards,
Chris
 
     Top
dloneranger
Posted: Jul 7 2011, 03:03 PM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



a few points

you can't just multiple the width by y for the next lines - there's no guarantee that they are contiguous
use the source and destinations pitch values instead
eg srcpixel =source.dat + x + (y * src.pitch)

consider other bitsperpixel it in GetParams eg 24bpp
it would look more like
CODE

switch ( fa->src.mpPixmapLayout->format )
   {    
     case nsVDXPixmap::kPixFormat_RGB888: // if you accept 24bits per pixel
       return FILTERPARAM_SWAP_BUFFERS | FILTERPARAM_PURE_TRANSFORM | FILTERPARAM_SUPPORTS_ALTFORMATS;
       break;
     case nsVDXPixmap::kPixFormat_XRGB8888:  //if you accept 32 bits per pixel
       return FILTERPARAM_ALIGN_SCANLINES | FILTERPARAM_SWAP_BUFFERS | FILTERPARAM_PURE_TRANSFORM | FILTERPARAM_SUPPORTS_ALTFORMATS;
       break;

     default:
       return FILTERPARAM_NOT_SUPPORTED;
   }


if the pixels are 32bit then don't invert the alpha channel, just the r,g and b
it's currently unused iirc, but could be used in the future, breaking your plugin


--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
phaeron
Posted: Jul 9 2011, 09:34 PM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



If you return FILTERPARAM_SWAP_BUFFERS, you are saying that the src and dst buffers should be different. That means your filter needs to put something in the dst buffer. What you're seeing is just whatever is already in that memory.

You need to use the pitch value as dloneranger says, and in particular it can be negative. Note that it is in bytes and not elements.

The alpha channel does not need any special handling with the default XRGB8888 format. This format will never be changed to make alpha pertinent -- that would be introduced as a different format.
 
    Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
2 replies since Jul 6 2011, 11:10 PM Track this topic | Email this topic | Print this topic

<< Back to VirtualDub Development Forum