PDA

View Full Version : XViD Configuration Dialog


GaveUp
7th August 2005, 04:20
I'm working on a program and I want to add the ability to pop up the XViD configuration dialog and set parameters for 1st and 2nd pass, and save these settings to be used by launching virtualdub. Popping up the configuration dialog is simple enough, just a matter of calling the dll via rundll32, but how do I save the configuration?

squid_80
7th August 2005, 06:20
Your program will need to export (save) and import (load) the registry settings in HKEY_CURRENT_USER\Software\GNU\Xvid.

GaveUp
7th August 2005, 07:26
Thanks for the quick response! Related, I was looking through the keys and noticed the target_size key. I don't see how it relates to the target size specified, though. For example, the last setting I used was 1005903 and the target_size value is 0x000A2800. Is there some sort of rounding going on here that the values don't match up 1:1?

squid_80
7th August 2005, 08:43
The target size for the encoded video is actually in the desired_size key. Target_size is the last used value for target size in the bitrate calculator. :sly:

stax76
7th August 2005, 11:33
I'm working on a program and I want to add the ability to pop up the XViD configuration dialog and set parameters for 1st and 2nd pass, and save these settings to be used by launching virtualdub.

You have to decide if you need to access certain values e.g. setting the bitrate, if this is the case than you work with the registry at least for DivX, XviD and maybe some other codecs that want to be supported in DVX, GK etc. You can download the sources for these apps btw.

MeteorRain
18th August 2005, 04:50
Popping up the configuration dialog is simple enough, just a matter of calling the dll via rundll32, but how do I save the configuration?
When user press the "OK" button, the configuration is saved = =+
am i right?

DaveEL
18th August 2005, 19:46
If you call the config dialog via the VFW api rather then directly on the xvid dll you will be passed back the codec config. You can then put it in a virtualdub script instead.

Dave

stax76
18th August 2005, 23:39
If you call the config dialog via the VFW api rather then directly on the xvid dll you will be passed back the codec config. You can then put it in a virtualdub script instead.


I'm doing this in DVX in case somebody needs source code.

GaveUp
29th August 2005, 21:24
I'm doing this in DVX in case somebody needs source code.

I'll take a look. Any chance you can narrow down where in the source the applicable code is? Judging from size of the download there's more than a fair bit of code to go through.

stax76
29th August 2005, 22:30
I hardly know what's going on there, code is pretty old, it was my first interop work, I might add support for all installed VFW codecs to my DVX successor so I might have to work with the code again


Public Sub SetCompData(ByVal byteArray As Byte())
If Not byteArray Is Nothing Then
Script.AddLine("video.SetCompData", "VirtualDub.video.SetCompData(" + byteArray.Length.ToString() + ",""" + Convert.ToBase64String(byteArray) + """);")
End If
End Sub



Imports System.Runtime.InteropServices

Public Class VFW
Public Shared Sub ShowEncoderForm(ByVal fccCode As String, ByVal owner As IntPtr)
Dim hic As Integer = GetEncoderHandle(fccCode, ICMODE.QUERY)
ICSendMessage(hic, ICM.CONFIGURE, owner, 0)
ICClose(hic)
End Sub

Public Shared Function GetEncoderHandle(ByVal fccCode As String, ByVal mode As ICMODE) As Integer
Dim fccType, fccHandler As Integer
fccType = mmioStringToFOURCC("vidc", MMIO.TOUPPER)
fccHandler = mmioStringToFOURCC(fccCode, MMIO.TOUPPER)
Return ICOpen(fccType, fccHandler, mode)
End Function

Public Shared Function ShowEncoderForm(ByVal byteArray As Byte(), ByVal fccCode As String, ByVal owner As IntPtr) As Byte()
Dim hic As Integer = GetEncoderHandle(fccCode, ICMODE.QUERY)
Dim size As Integer = ICSendMessage(hic, ICM.GETSTATE, 0, 0)
Dim memoryBlock As IntPtr = Marshal.AllocHGlobal(size)

If byteArray Is Nothing Then
byteArray = New Byte(size - 1) {}
Else
Marshal.Copy(byteArray, 0, memoryBlock, size)
ICSendMessage(hic, ICM.SETSTATE, memoryBlock, size)
End If

ICSendMessage(hic, ICM.CONFIGURE, owner, 0)
ICSendMessage(hic, ICM.GETSTATE, memoryBlock, size)
Marshal.Copy(memoryBlock, byteArray, 0, byteArray.Length)
ICClose(hic)
Marshal.FreeHGlobal(memoryBlock)

Return byteArray
End Function

Public Enum ICMODE
QUERY = 4
End Enum

Public Enum ICM
GETSTATE = 20480
SETSTATE = 20481
CONFIGURE = 20490
End Enum

Public Enum MMIO
TOUPPER = 16
End Enum

<DllImport("msvfw32.dll")> _
Public Shared Function ICClose(ByVal hic As Integer) As Integer
End Function

<DllImport("msvfw32.dll")> _
Private Shared Function ICOpen(ByVal fccType As Integer, ByVal fccHandler As Integer, ByVal wMode As Integer) As Integer
End Function

<DllImport("msvfw32.dll")> _
Private Shared Function ICSendMessage(ByVal hic As Integer, ByVal msg As Integer, ByVal dw1 As Integer, ByVal dw2 As Integer) As Integer
End Function

<DllImport("msvfw32.dll")> _
Private Shared Function ICSendMessage(ByVal hic As Integer, ByVal msg As Integer, ByVal dw1 As IntPtr, ByVal dw2 As Integer) As Integer
End Function

<DllImport("winmm.dll")> _
Private Shared Function mmioStringToFOURCC(ByVal sz As String, ByVal uFlags As Integer) As Integer
End Function
End Class

DaveEL
30th August 2005, 16:40
If you want source from some more basic applications (DVX is a lot bigger iirc) to get you started avs2avi does the show the dialog and get the configuration information back but just writes it raw to a file.
In terms of writing it to a virtualdub script is should be easy enough to find the code in quick2pass. source for both (although not the current version of avs2avi but that doesn't matter for your purposes) should at http://daveel.dnsalias.com

DaveEL