Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VirtualDub, VDubMod & AviDemux

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th May 2017, 21:47   #261  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
@shekh
Thx, looking good for CodecPrivate, AVCConfigurationBox and MKV AR.

I see it sets H.264 matrix coefficients flag. How does it decide which one is set?
sneaker_ger is offline   Reply With Quote
Old 14th May 2017, 21:53   #262  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,753
Quote:
Originally Posted by raffriff42 View Post
... "copy output frame to clipboard" returns nothing but a black rectangle. Adding a ConvertFormat: RGB32 filter solves the problem.
This feature will probably only work with DIB compatible formats...
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 14th May 2017, 22:08   #263  |  Link
shekh
Registered User
 
Join Date: Mar 2015
Posts: 775
Quote:
Originally Posted by sneaker_ger View Post
@shekh
Thx, looking good for CodecPrivate, AVCConfigurationBox and MKV AR.

I see it sets H.264 matrix coefficients flag. How does it decide which one is set?
Colorspace matrix? Virtualdub understands 2 types of matrix 601/709. So it is set to one of these when encoding.
__________________
VirtualDub2
shekh is offline   Reply With Quote
Old 14th May 2017, 22:09   #264  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Quote:
Originally Posted by LigH View Post
This feature will probably only work with DIB compatible formats...
I know, but it's probably easy to downconvert. But, now that you mention it, maybe silent downconversion should not be done. OK, how about either (a) disabling the copy function when it can't succeed and changing (grayed-out) menu text to "(cannot copy this format)" or (b) a popup message when copying fails.

Copying any non-standard format to the clipboard is probably complicated. IIRC you have to render multiple versions of your data so each client application gets the best version it can accept (see: Photoshop etc). I can understand if shekh gives a very low priority to something like that.
raffriff42 is offline   Reply With Quote
Old 14th May 2017, 22:36   #265  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Quote:
Originally Posted by shekh View Post
Colorspace matrix? Virtualdub understands 2 types of matrix 601/709. So it is set to one of these when encoding.
So only "Video">"Decoder format"? "Alias format" filter seems to be ignored.
sneaker_ger is offline   Reply With Quote
Old 15th May 2017, 10:21   #266  |  Link
shekh
Registered User
 
Join Date: Mar 2015
Posts: 775
Quote:
Originally Posted by raffriff42 View Post
I know, but it's probably easy to downconvert. But, now that you mention it, maybe silent downconversion should not be done. OK, how about either (a) disabling the copy function when it can't succeed and changing (grayed-out) menu text to "(cannot copy this format)" or (b) a popup message when copying fails.

Copying any non-standard format to the clipboard is probably complicated. IIRC you have to render multiple versions of your data so each client application gets the best version it can accept (see: Photoshop etc). I can understand if shekh gives a very low priority to something like that.
"Copy to clipboard" is supposed to always convert to rgb24.
Afaik no other clipboard picture format is widely supported; I tried to support alpha channel and gave up.

Why it does not work with some formats should be fixed, for some (historical?) reasons VD implemented 2 picture conversion routines: one is normal and the other (used for clipboard copy) covers only subset of formats.
__________________
VirtualDub2
shekh is offline   Reply With Quote
Old 15th May 2017, 11:29   #267  |  Link
shekh
Registered User
 
Join Date: Mar 2015
Posts: 775
Quote:
Originally Posted by sneaker_ger View Post
So only "Video">"Decoder format"? "Alias format" filter seems to be ignored.
When you setup output codec there are 2 possible ways:

1) explicit - navigate to compression -> pixel format, set colorspace to rec 709

2) auto - when compression->pixel format is set to auto, it will match source file format/colorspace (not last filter!)
However "auto" is disabled with x264 codec.

"no change" option for colorspace seems ill-defined for output (in most cases it means default=601).

If you want to keep filter output as is, you need to repeat same settings as the filter.
For example:
If your last filter is alias format "709-FR"
Select "709-FR" in compression->pixel format dialog (it will be indicated in "save video" too).
In this setup there will be no colorspace change between filters and compression.
__________________
VirtualDub2
shekh is offline   Reply With Quote
Old 23rd May 2017, 09:55   #268  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
SDK evolution suggestion.

I'm still using "standard" SDK, didn't make the leap to use yours yet (but intend to in a not too far future), but i've made a small change, maybe you can do the same in your next release.

The VDXVideoFilter class offers a "constructor" with the Init function, but doesn't offer a "destructor".
So, i've added a DeInit function (because i needed it).

The following change in the code are:

VideoFilter.h
Code:
	virtual bool Init();
	virtual void DeInit();
	virtual uint32 GetParams()=0;
VideoFilter.cpp
Code:
bool VDXVideoFilter::Init() {
	return true;
}

void VDXVideoFilter::DeInit() {
}

void VDXVideoFilter::Start() {
}
....

void __cdecl VDXVideoFilter::FilterDeinit   (VDXFilterActivation *fa, const VDXFilterFunctions *ff) {
	VDXVideoFilter *pThis = *reinterpret_cast<VDXVideoFilter **>(fa->filter_data);

	pThis->fa=fa;
	pThis->DeInit();
	pThis->~VDXVideoFilter();
}
Do you think it's something you can add in your next release ?
jpsdr is offline   Reply With Quote
Old 23rd May 2017, 10:10   #269  |  Link
shekh
Registered User
 
Join Date: Mar 2015
Posts: 775
Just checked, this is not necessary.

There is virtual destructor:

Code:
class VDXVideoFilter {
public:
	VDXVideoFilter();
	virtual ~VDXVideoFilter();
And it is called exactly from DeinitProc wrapper:

Code:
void __cdecl VDXVideoFilter::FilterDeinit   (VDXFilterActivation *fa, const VDXFilterFunctions *ff) {
	(*reinterpret_cast<VDXVideoFilter **>(fa->filter_data))->~VDXVideoFilter();
}
virtual DeInit does not add any value here
__________________
VirtualDub2
shekh is offline   Reply With Quote
Old 23rd May 2017, 10:25   #270  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
Yes, but how do i put the code i need to run on "destructor" if i don't create the DeInit function ?
Because you musn't create your own constructor/destructor in your filter, because of the copy there is sometimes, so if you want a specific code to be run on constructor, you have to put it on Init function, but it's missing actualy a DeInit function to do the same thing.
Because of the interface, there is "copy constructor" operations on the instance filter, when you call the interface menu, etc. The existance of the Init function ensure that a specific constructor code will be run only once, and not several times, and the same with the DeInit.
You can't create/change the destructor (and also the constructor), to put your code, otherwise it will be called each time a copy of the object will be created.
There is the Init function for that for the constructor, but there is not such function for the destructor.
The value added by DeInit is to ensure that your code wil be runned only when the system will call FilterDeinit.
The same way Init ensure that your code wil be runned only when the system will call FilterInit.

Last edited by jpsdr; 23rd May 2017 at 10:30.
jpsdr is offline   Reply With Quote
Old 23rd May 2017, 11:25   #271  |  Link
shekh
Registered User
 
Join Date: Mar 2015
Posts: 775
I say DeInit has no value because it does not do anything differently.
You can see in your code:

Code:
void __cdecl VDXVideoFilter::FilterDeinit   (VDXFilterActivation *fa, const VDXFilterFunctions *ff) {
	VDXVideoFilter *pThis = *reinterpret_cast<VDXVideoFilter **>(fa->filter_data);

	pThis->fa=fa;
	pThis->DeInit();
	pThis->~VDXVideoFilter();
}
DeInit and destructor are called in a row. There is no other entry point to either one! So you can just move code from DeInit to destructor and it will be the same.

Quote:
you musn't create your own constructor/destructor in your filter
Wrong, you must create them!

I understand the idea of Init-Deinit symmetry, but it is impossible. The instance can be created differently, but is must always destroy itself the same way, no matter how it was created. There is no way you can run a complete destructor for "initial" object and partial destructor for cloned object. This cannot work.

I remember the copy-constructor issue.

The proper filter example:

Code:
class Filter: public VDXVideoFilter {
public:
  Param param;
  void* buf;

  Filter(){ init(); }
  Filter(const Filter& a){ init(); param=a.param; }
  void init(){ buf=0; }
  ~Filter(){ free(buf); }
};
Here I have:
default constructor "Filter(){ init(); }"
copy constructor "Filter(const Filter& a){ init(); param=a.param; }"
helper function to avoid typing the same shit in both constructors "void init(){ buf=0; }"
destructor "~Filter(){ free(buf); }"

This is bare generic minimum to implement/think of.

What If instead I write something like this:

Code:
class Filter: public VDXVideoFilter {
public:
  Param param;
  void* buf;

  virtual Init(){ buf=0; }
  virtual DeInit(){ free(buf); }
};
Because I do not declare copy constructor it defaults to something like this:
Code:
  Filter(const Filter& a){ param=a.param; buf=a.buf; }
So when the clone object is created it will share the same memory block pointed by buf, eventually this will result in double-free memory corruption.
How do you plan to sort this with virtual DeInit? It does not help at all. Only copy constructor can decide what to do.
__________________
VirtualDub2
shekh is offline   Reply With Quote
Old 23rd May 2017, 12:19   #272  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
Quote:
There is no way you can run a complete destructor for "initial" object and partial destructor for cloned object.
It think it's possible if the system call FilterInit and FilterDeinit only on "initial" object, and not the cloned.
This way, on cloned objet, "partial" constructor/destructor, without the specific code put in Init/DeInit will not be called.
And if "buff" is not allocated in constructor, but in Start, it must be freed in End, not DeInit or destructor.
The exemple code you put is not compatible with the filter SDK way. You de-allocate things on FilterDeinit (or deinitProc) only if they have been allocated on FilterInit (or initProc).

When you look at the SDK 1.2 help, in "Reference -> Video filter functions", there is initProc and deinitProc. All the "constructor stuff" must be put on initProc, and all the "destructor stuff" in deinitProc, they are "symmetrical", that what the SDK help says (well... not fully, because you can throw exceptions on initProc but not on deinitProc, but if we leave this appart). The Init in VDXVideoFilter class is somhow a wrapper to initProc (the same there is for Start/startProc, etc...), but there is actualy no wrapper for deinitProc, this is what i intended to do with DeInit.

Of course, SDK said also to put maximum allocation/buffer in Start and free of these in End, but there is things i have to do in initProc and deinitProc, and not in Start and End.

Last edited by jpsdr; 23rd May 2017 at 13:08.
jpsdr is offline   Reply With Quote
Old 23rd May 2017, 12:57   #273  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Quote:
Originally Posted by shekh View Post
2) auto - when compression->pixel format is set to auto, it will match source file format/colorspace (not last filter!)
What do you think of showing the current format, alongside the auto-selected output format, where they are different? Maybe something like this:

.
raffriff42 is offline   Reply With Quote
Old 23rd May 2017, 13:16   #274  |  Link
shekh
Registered User
 
Join Date: Mar 2015
Posts: 775
The part you probably misread in the sdk:

Quote:
With copyProc, it becomes possible to map the allocation and deallocation hooks onto traditional C++ object semantics, which makes filter data management much easier. In particular, the three hooks can be mapped as follows:

Filter API entry point Equivalent C++ method
initProc Constructor
deinitProc Destructor
copyProc Copy constructor
Quote:
It think it's possible if the system call FilterInit and FilterDeinit only on "initial" object, and not the cloned.
But it is not, as soon as clone object is created both objects are equal in rights. FilterDeinit/destructor is called equally for both.

Quote:
And if "buff" is not allocated in constructor, but in Start, it must be freed in End, not DeInit or destructor.
You can allocate stuff in constructor, init, start, run, config or anywhere else. There is no rule against this.
The only sane rule is: everything you allocate must be reasonably freed.
Where exactly to put something can only be advice, not rule.

btw can you share sdk 1.2? It seems I have lost it (only 1.1 is still on virtualdub.org)

If you want to read help to the letter:

Quote:
initProc
Initializes a filter's per-instance data.

int initProc(VDXFilterActivation *fa, const VDXFilterFunctions *ff);

Remarks
This function is called whenever a filter instance is created, and is usually used to initialize variables in the private data structure. Regardless of whether it is provided, VirtualDub will initialize the data structure to zeroes, so most filters will not need this function.
ok except it does not mention that it is NOT called when copy instance is created, which somewhat changes the game.

Quote:
copyProc
Creates a clone of the filter instance.

int copyProc(VDXFilterActivation *fa, const VDXFilterFunctions *ff, void *dst);

Remarks
This function allows you to implement a copy constructor for your filter, which then allows you to store pointers to allocated and destructable objects in your filter structure. To do this, you must tie copyProc to your class's copy constructor, initProc to your regular constructor, and deinitProc to your destructor. See using a class object for your filter for more details.
again (translating)
initProc = Constructor (constructor is wrapper for initProc)
deinitProc = Destructor (destructor is wrapper for deinitProc)
copyProc = Copy constructor (copy constructor is wrapper for copyProc)

Do you still insist to ignore copy constructor?

Why there exists virtual VDXVideoFilter::Init? IMO you are supposed to ignore it unless you want to return error to deny filter usage (maybe it cannot find required library).
Init is called anyway after constructor is called but there is no way to return error from a constructor.
__________________
VirtualDub2
shekh is offline   Reply With Quote
Old 23rd May 2017, 13:31   #275  |  Link
shekh
Registered User
 
Join Date: Mar 2015
Posts: 775
Quote:
Originally Posted by raffriff42 View Post
What do you think of showing the current format, alongside the auto-selected output format, where they are different? Maybe something like this:

.
Do you mean "current" = whatever is coming to output pane?
I think it is good idea to show all steps

"source (YUV420) -> filters (RGB24) -> compression (YUV420)"
__________________
VirtualDub2
shekh is offline   Reply With Quote
Old 23rd May 2017, 13:39   #276  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
I'll send you by mail the SDK when back home. So, according what you said, the "only" purpose of VDXVideoFilter::Init is to be able to return value and throw exception.
If i don't want to do either of them, i could just create a constructor (and also a destructor if needed) of my filter class, and it will also do the trick.
Ok.
I'll restore to the original, and add a destructor to my filter created from VDXVideoFilter instead do to the DeInit job, and keep Init, as it's allready implemented.
jpsdr is offline   Reply With Quote
Old 24th May 2017, 07:40   #277  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Quote:
Originally Posted by shekh View Post
I think it is good idea to show all steps

"source (YUV420) -> filters (RGB24) -> compression (YUV420)"
Sure, that would be even better.
raffriff42 is offline   Reply With Quote
Old 24th May 2017, 11:40   #278  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by jpsdr View Post
I'll send you by mail the SDK
Posting link would be nicer and available to anyone

EDIT: VDub Filter SDK versions v1.00, v1.05, and v1.10
EDIT: LINK DELETED
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 24th May 2017 at 12:09.
StainlessS is offline   Reply With Quote
Old 24th May 2017, 12:03   #279  |  Link
shekh
Registered User
 
Join Date: Mar 2015
Posts: 775
Quote:
Originally Posted by StainlessS View Post
Posting link would be nicer and available to anyone
Added here so hopefully I dont lose it again.
Anyone has source code for these chm docs?
__________________
VirtualDub2
shekh is offline   Reply With Quote
Old 24th May 2017, 12:09   #280  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
All versions in one package, VDUB_FiltSDK_1-00_1-05_1-10_1-20.zip
http://www.mediafire.com/file/axfipb..._1-10_1-20.zip
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 19:52.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.