Download for Windows Download for Linux Download for FreeBSD Download for Mac Manual Wiki Forum IRC Trac

Tuesday, July 22, 2008

Random code-snippets from VSFilter

I've been reading and hacking on the VSFilter code more than is probably healthy, and have over the time found a lot of funny/strange clips of code.

For example, this line in GFN.cpp (Get File Name):

CString filename = title + _T(".nooneexpectsthespanishinquisition");


In VSFilter.cpp you can find this gem:
/*removeme*/
JajDeGonoszVagyok();



Do you know the "opaque box" background style supported? As an alternative to wide outlines? Well here's how it's created:
CStringW str;
str.Format(L"m %d %d l %d %d %d %d %d %d",
-w, -w,
m_width+w, -w,
m_width+w, m_ascent+m_descent+w,
-w, m_ascent+m_descent+w);

m_pOpaqueBox = new CPolygon(style, str, 0, 0, 0, 1.0/8, 1.0/8, 0);

Yup, it creates a drawing object, by a string. While it is a bit clever (the alternative would be much more code) it has some bad problems which you may have seen if you've used it yourself: If for any reason it needs to create multiple boxes, such as when you have multiple lines, the boxes will overlap and a non-zero alpha will make that look really bad.

I wonder how long this line has been sitting there:
// TODO: handle collisions == 1 (reversed collisions)


Maybe pre-buffering could be more useful if this was actually implemented:
STDMETHODIMP_(bool) CRenderedTextSubtitle::IsAnimated(POSITION pos)
{
// TODO
return(true);
}


I still find this the weirddest part... there is a CPP file with a stange name. It contains among other things this function:
#define LEN1 (countof(str1))
#define LEN11 (countof(str1[0]))
#define LEN2 (countof(str2))
#define LEN3 (countof(str3))

static void dencode()
{
int i, j;
for(i = 0; i < LEN1; i++) for(j = 0; j < LEN11; j++) str1[i][j] ^= 0x12;
for(i = 0; i < LEN2; i++) str2[i] ^= 0x34;
for(i = 0; i < LEN3; i++) str3[i] ^= 0x56;
}

If you think it looks like XOR en/decryption you're right. That's exactly what it is.

It's from the file containing the void JajDeGonoszVagyok() function, and it's called "valami.cpp". This file also contains one other strangely named function: bool HmGyanusVagyTeNekem(IPin* pPin)

Both of those functions decrypt some strings written as arrays of numbers. These strings are the names of registry keys of other DirectShow filters. The JajDeGonoszVagyok function then detects the highest merit of all those filters and makes sure that DirectVobSub itself gets a merit higher than any of those... I think this is the DirectShow version of the "law of the jungle".

Related Posts by Categories



16 comments:

  1. As equinox so wisely remarked, Gabest gives a new definition to "hungarian notation".

    Or, as movax said, vsfilter is like the Millennium Falcon.

    ReplyDelete
  2. Great article! I've been doing some hacking myself, searching for a way to set the subtitle source file name programatically from within a DirectShow app. Is this doable?

    ReplyDelete
  3. You can do all king of programming so easily if you can d typing fastly. The typing services uk is all about typing techniques that will help you to done your work.

    ReplyDelete


  4. The share your really gives us excitement. Thanks for your sharing. If you feel tired at work or study try to participate in our games to bring the most exciting feeling. Thank you!
    hotmail login | red ball | 192.168.1.1

    ReplyDelete
  5. The blog or and best that is extremely useful to keep I can share the ideas of the future as this is really what I was looking for, I am very comfortable and pleased to come here. Thank you very much.
    animal jam | five nights at freddy's | hotmail login

    ReplyDelete
  6. Thank you for the information. This is well written and gives a lot of value for people who are looking to learn

    ReplyDelete
  7. Your blog provided us with valuable information to work with. Each & every tips of your post are awesome. Thanks a lot for sharing. Keep blogging.
    bollywood gossip
    serial actresses hot photos

    ReplyDelete

If you need help with Aegisub or have a bug report please use our forum instead of leaving a comment here. If you have a feature request, please go to our UserVoice page.

You will get better help on our forum than in the blog comments.