[PATCH] Pinvoke compatibility update for libhb

Archive of historical development discussions
Discussions / Development has moved to GitHub
Forum rules
*******************************
Please be aware we are now using GitHub for issue tracking and feature requests.
- This section of the forum is now closed to new topics.

*******************************
Post Reply
RandomEngy
Novice
Posts: 50
Joined: Thu Mar 29, 2007 2:56 am

[PATCH] Pinvoke compatibility update for libhb

Post by RandomEngy »

http://engy.us/misc/pinvoke_compatibility.patch

This does two major things:

1) Adds some wrapper and setter methods. You have a limited way of interacting with unmanaged memory when you use P-invokes, which makes directly modifying structures impossible. Libhb currently relies on this in several ways, so I need to add these native methods to do this interaction.

2) Adds hb_register_logger, which allows you to get log messages passed to a given callback. Much like hb_register_error_handler, except this will pass through everything on stderr. This includes HB log messages and other messages, like from x264.

There's also a bit of refactoring around process initialization.
RandomEngy
Novice
Posts: 50
Joined: Thu Mar 29, 2007 2:56 am

Re: [PATCH] Pinvoke compatibility update for libhb

Post by RandomEngy »

Updated patch to apply to latest SVN.
User avatar
s55
HandBrake Team
Posts: 10360
Joined: Sun Dec 24, 2006 1:05 pm

Re: [PATCH] Pinvoke compatibility update for libhb

Post by s55 »

Ran a few test sources with this patch applied and didn't have any problems with the encodes.

I do appear to be seeing encodes that are a fair bit slower. I'll need to do some testing to see if this is patch related or if we have something else going on. Seems to be around 50~70fps slower on universal. (It's possibly not the patch since I've been using a fairly old build in my test setup.)
User avatar
s55
HandBrake Team
Posts: 10360
Joined: Sun Dec 24, 2006 1:05 pm

Re: [PATCH] Pinvoke compatibility update for libhb

Post by s55 »

Looks like it's something else. 3154 seems a bit slower too :/

So I'm fine with this going in if the code looks ok.
RandomEngy
Novice
Posts: 50
Joined: Thu Mar 29, 2007 2:56 am

Re: [PATCH] Pinvoke compatibility update for libhb

Post by RandomEngy »

Patch updated. Had a bug with picking titles from DVDs with invalid titles.
User avatar
JohnAStebbins
HandBrake Team
Posts: 5726
Joined: Sat Feb 09, 2008 7:21 pm

Re: [PATCH] Pinvoke compatibility update for libhb

Post by JohnAStebbins »

Committed with a couple minor modifications http://trac.handbrake.fr/changeset/3317

I have a question about how you are using hb_get_filter_object however. Are the strings that are being strdup'd there being freed somewhere? It's usually bad practice to have one piece of code alloc memory and another free it. But I can see where this might be necessary in the interface to C#.
RandomEngy
Novice
Posts: 50
Joined: Thu Mar 29, 2007 2:56 am

Re: [PATCH] Pinvoke compatibility update for libhb

Post by RandomEngy »

Thanks!

I see what you mean about the settings strings. When the CLI interacts with the filter objects, it is allocating the strings and can clean them up if it wants to. In this case, no one appears to have responsibility for them. I believe that I'll need to manually marshal the string in the interop and keep it around until the job is complete. Then in hb_get_filter_object we don't need to strdup, we can just set the char* directly. Want me to come up with a patch? Though the change is pretty simple, you could just check it in yourself.
User avatar
JohnAStebbins
HandBrake Team
Posts: 5726
Joined: Sat Feb 09, 2008 7:21 pm

Re: [PATCH] Pinvoke compatibility update for libhb

Post by JohnAStebbins »

Yes, please create a patch to fix this. You're going to need to test it anyway since your code is currently the only one that uses this function.
Post Reply