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

Friday, July 25, 2008

How VSFilter renders border and shadow

If you've ever used the \be or the new \blur tag you might wonder, why do they blur edges and not everything?

Example of how VSFilter blurs just edges and not everything
The answer lies in how VSFilter internally handles fill, border and shadow, and the relationship between them.

The basic component of a subtitle rendering is the fill. The fill is the main shape of the text, ie. what you see if you disable border and shadow. (When I write "text" here it can just as well be a vector drawing made with \p1.)

I am keeping things simple here, there are some technical details in the actual implementation I'm skipping over because they aren't relevant for the discussion, although they actually impact the actual algorithm used greatly. I might discuss the detailed algorithm later.

When I talk about bitmaps in this post, they are single-channel bitmaps, ie. black/white bitmaps. Colour is applied during the painting-step, this is described in detail below.

When a subtitle is to be rendered, VSFilter first creates a bitmap of the text fill. It then sees if the text should have a "wide outline", ie. if a \bord tag is in effect. If there is a wide outline, it allocates an additional bitmap that will contain the widened region.

The widened region is the fill bitmap modified in a way so it's effectively "embolded", ie. the outline is expanded outwards, but the entire fill is still kept.

Visualisation of how the widened region is the fill expanded outwards by border size
You might notice that the widened region looks a lot like the shadow. This is entirely correct, because it is used for rendering not just the border but also the shadow.

When the line is to be rendered, the fill bitmap is used as-is for fill, the widened region is used as-is for shadow, and the border is generated by subtracting the fill from the widened region, ie. the border is the part of the widened region that is not also in the fill.

Things work a little different when there is no border. In that case, the fill is painted as-is, but the shadow is also painted using the fill.

I wrote above that the fill and widened region bitmaps are black/white bitmaps, so what about colour? The bitmaps are simply re-coloured with the selcted colour during painting, or more correctly, used as alpha masks to paint a frame full of the colour.

Okay, so on to the blur effects.

The blur effects are applied to the bitmaps, either to the fill or to the widened region bitmap. If there is a widened region bitmap, it is applied to that one only and the fill is left alone. If there is no widened region (ie. no border) the blur is applied to only the fill bitmap.

This is why only the border blurs when you use \be or \blur along with a border, and why the fill does blur when you use blur on lines with no border: The fill bitmap is rendered on top of the blurred border, even though the border blur extends below the fill.

Related Posts by Categories


  1. Another enjoyable article!

    I guess the blurring employed by VSFilter runs a weighted kernel across the bitmap. Does it use a source and clone bitmap for this or just the source? The results can be quite different. What size kernel is used? 3x3? 5x5? Or does this depend on the user-selected depth? In other words, if it uses a 3x3 kernel (blur = 1) and the user wants a blur depth of 2, does it run the 3x3 code twice or increase the size of the kernel to 5x5? Is the blur process split into two passes (vertical and horizontal) to increase rendering speed? And is true Gaussian blurring used or just an approximation?

    Sorry for all the questions! I find this stuff fascinating, having knocked myself out for 24 months adding a pseudo-Gaussian blur to our app's bitmap subtitles. And I'm still not happy with the results! ( :)

  2. Heh, late reply (somehow hadn't noticed this comment before) but here's an answer anyway.

    The \be tag uses a simple 3x3 matrix, [ 1 2 1; 2 4 2; 1 2 1 ]. It is not applied in a separated manner but just as a 3x3 convolution.

    With the "extended \be" patch you can give a larger parameter than 1 to \be, this causes the convolution to be applied that number of times. As the image in the main post shows, the results aren't very pretty.

    The \blur tag uses a real gaussian kernel applied as a separated filter. It is an approximated kernel, the elements are unsigned bytes ie. 0-255 range, and rather than being of infinite length it uses a cutoff which should be large enough to get the significant part of it.

  3. I put {\be10} in my video, and i when i encode it with x264 it doesnt show :( What is the problem? I also use K-Lite codec pack. Can someone please help me out?

  4. Please ask your support question in the forums, not in a blog comment.

  5. This is what I have been searching in many websites and I finally found it here. Amazing article. I am so impressed. Could never think of such a thing is possible with it...I think you have a great knowledge especially while dealings with such subjects.

  6. The outline which expanded towards the is used for retendering about their services.

  7. Things work a little different when there is no border. In that case, the fill is painted as-is, but the shadow is also painted using the psy d dissertation.

  8. from the website here you can easily access facebook account of other with getting the password from the link here.

  9. I have been seeking in numerous sites and I at long last discovered it here. Astonishing article. I am so awed.paid facebook followers

  10. This is great information for students. This article is very helpful i really like this blog thanks. facebook usa likes

  11. This is really good information I have visited this blog to read something fresh and I really admire you efforts in doing so. buy targeted facebook likes

  12. First You got a great blog.I will be interested in more similar topics.
    happy wheels
    happy wheels

  13. Thanks for sharing this nice article. and i wish to again on your new blog keep sharing with your article.
    Thanks For Share....

  14. Great writing it is such a good and nice idea thanks for sharing your article .I like your post.

  15. Hello, thanks for taking the time to view my profile. I am an academic writer from the US who enjoys finding new topics to research and write about.
    Assignment writing Help

  16. I was working and suddenly I visits your site frequently and recommended it to me to read also. Age Of War 2
    Big Farm | Slitherio
    Tank Trouble | Happy Wheels
    Goodgeme Empire |

  17. Love your blog!! Why don't you blog anymore :( I miss your blog. Wahhh
    watergirl and fireboy
    Geometry Dash

  18. I very much agree with your comments. Your article is great. It helps me to know many things that previously I did not pay any attention to. Ask permission to share:
    Run 2 game - Run 2 unblocked - Run 2 game

  19. Thank you for visiting our site. Sure you will feel is amazing. Since we have been very selective as many games and you can play online for free
    gun mayhem 3 | tank trouble 3
    learn to fly 3 | happywheels
    tank trouble |

  20. Facebook has become a part of my life, not only helped me to connect with you but also where I can share every moment in life. I really like the convenience that it brings
    facebook baixar , baixar facebook , facebook baixar , baixar facebook , facebook baixar , baixar facebook gratis

  21. The article gives me a lot of interesting information. I still often share life experiences with friends. And I enjoyed the convenience and attractiveness of free messaging app
    whatsapp baixar , baixar whatsapp , whatsapp baixar , baixar whatsapp gratis

  22. Great information I will tweet to my friends to get them to check it out. keep it up. Thanks for sharing!.If have a long time than visit to:
    crosswords puzzles | dream league soccer apk | cookie clicker | dream league soccer apk | crossword puzzles | cookie clicker

  23. After a decisive Gold Medal-winning game over Serbia, Nike Basketball commemorates the achievement with a KD 9, Kyrie 2, Curry 3 USA and Lebron Soldier 10.Each sneaker’s theme within the pack is simple, a touch of Kobe 10 gold mixed with other colors. Both the Kyrie and KD models feature red to Curry 3 Dub Nation match the USA jerseys, while the former features a black upper and an icy Kobe 6 blue sole. The LeBron Soldier 10 not only matches the golden sneaker trend to LeBron 10 a tee with white and gold throughout, the shoe actually looks like one of Jordan Basketball Shoes the PEs that LeBron James wore in the NBA Finals.You can pick up either kobe bryant shoes the KD 9, Kyrie 2, or LeBron Soldier 10 in the Nike Basketball Gold James Harden Shoes Medal Pack at the links below each picture:
    Jordan Brand celebrates Kobe Bryant’s first Kobe Bryant Shoes year out of the NBA with a special edition Air Jordan 9 Kobe release.Dressed Kyrie 2 in a White, Concord and Tour Yellow color scheme. This Air Jordan 9 is Cavalier Steam Shop a nod to Kobe’s original Air Jordan 9 PE in the Los Angeles Lakers Derrick Rose Shoes home colors. Featuring a White leather upper with Concord patent leather overlay and Yellow Kobe Venomenon 4 accents. A number “23” replaces the original Kobe number “8” on the heels.Look for Kobe 8 the Air Jordan 9 “Kobe” to release on November 19th, 2016 at select Jordan KD 6 Brand retail stores. The retail price tag is set at $190 USD.
    Following a

  24. Great article, I was very impressed about it, wish you would have stayed next share
    strikeforce kitty 2 | red ball 4 | strike force kitty | red ball 3 | ninjago games

  25. Life becomes more interesting and wonderful when you share your memorable moments with friends and family through unique photographs. You can create your own unique style impressed with image editing software. And after hours of work stress you can also

    tank trouble, tank trouble 2, tank trouble games, tank trouble

  26. Life becomes more interesting and wonderful when you share your memorable moments with friends and family through unique photographs. You can create your own unique style impressed with image editing software. And after hours of work stress you can also
    dr driving, dr driving baixar ,download dr driving, dr driving

  27. You need to have time to take care of the active. It in fact was a amusement account it. Look advanced to far added agreeable from you.

    banana kong download , banana kong , baixar banana kong , download banana kong , banana kong baixar

  28. Mostly people have all the same things when they are writing academic task or any other writing, especially light music most people like during the writing.

    subway surf , baixar subway surf, subway surf download , download subway surf

  29. Thanks I have read your article, it is very interesting and exciting
    download go launcher, go launcher apk, go launcher , go launcher androi,

  30. Mostly people have all the same things when they are writing academic task or any other writing, especially light music most people like during the writing.
    dream league soccer download , dream league soccer apk , download dream league soccer , dream league soccer

  31. E-mail with many attractive features and convenience are the choice of most people around the world open. And I want to share to everyone a free webmail services
    outlook entrar , entrar no outlook , entrar outlook , outlook entrar

  32. Very interesting blog. Alot of blogs I see these days don't really provide anything that I'm interested in, but I'm most definately interested in this one. Just thought that I would post and let you know. l wingsio l wings io l wingsio game l play wingsio


  33. 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 sign in | red ball 1

  34. I think this is among the most important information for me. And I love those who read the article. However, I would like to clarify a few key issues, Website articles are really excellent, ideal, Excellent job, applause

    Edirne Kombi Servisi

  35. Everyone loves the look and feel of a clean home. Thanks for choosing this topic for post and update me. Game Stick RPG 2 looks like your real life, you can get everything you want, game Douchebag workout 2 is to renew him, so that he can hook up with the sexy girl appearing in the introduction, return man 3 saves your progress, with Potty Racers do you want to fly to Mars with me?

  36. Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write.
    Thanks for sharing !
    tanki online 2 | 2048 game online

  37. Good article, but it would be better if in future you can share more about this subject. Keep posting.

  38. Are you currently eager to Buy YouTube Views? In this case, you're on correct page. We can help you for this issue. how to get subscribers on youtube

  39. Thanks for your post! Through your pen I found the problem up interesting! I believe there are many other people who are interested in them just like me! Thank you for sharing them with everyone!

  40. Thanks for your post! I believe there are many who feel the same satisfaction as I read this article! I hope you will continue to have such articles to share with everyone!
    slither io

  41. Not all are true. Everyone has their own way of thinking but I think they have to reconsider. I like to argue for the most accurate results.

  42. Thanks for your post! Through your pen I found the problem up interesting! I believe there are many other people who are interested in them just like me! Thanks your shared!... I hope you will continue to have similar posts to share with everyone! I believe a lot of people will be surprised to read this article!
    io games online

  43. I understand what you bring it very meaningful and useful, thanks.

  44. Ở Việt Nam, tỷ lệ phụ nữ mắc các bệnh phụ khoa rất cao, đa số mọi người thường nghĩ viêm nhiễm phụ khoa, đặc biệt là viêm âm đạo là chuyện bình thường.

    bệnh viêm phụ khoa là gì, biểu hiện bệnh viêm âm đạo, biểu hiện viêm nhiễm phụ khoa ,

  45. تخلص من جميع مشاكل الحشرات في شركة مكافحة حشرات لدينا ابادة حشرات للمولات وخدمات متخصصة للاماكن العامة والواسعه ابادة حشرات للمصانع وتخفيضات هائلة في ابادة حشرات للمطاعم ومبيدات متخصصة من افضل الانواع في مكافحة حشرات للجناين موقعنا:


  46. العاب تلبيس بنات موقع العاب
    تلبيس يعتبر الموقع هو الاول من نوعة في الالعاب التي يتم وضعها يوميا فهو موقع يعتمد بشكل كبير علي المحتوي الذي يتم تنزيلة بشكل هام للزائر من
    المعروف ان playcoatbanat
    بنات لها شعبية واسعة وكبيرة جدا فمثلا نجد في لعبة ولتكن لعبة تلبيس فتاة النحل نجد بها في البداية انتي ستلاحظين وجود فتاة لا ترتدي اي لبس مهمتك في
    هذه الالعاب الخاصة بالتلبيس هي وضع الملابس علي الفتيات ولكن انتبهي سيدتي فالموضوع لا يقتصر علي الملابس فقط ولكتن هناك ايضا وضع الشعر
    المزيف الملقب بالباروكة التي توضع علي الرأس وكذلك يمكنكي وضع وتلبسيها الحذاء الملون ايضا فهناك الوان عديدة مثل اللون الازرق فهو اللون المحبب
    لمعظم الاجيال الحالية وايضا يوجد اللون الاخضر وهو مميز لفتيات التلبيس الجميلات جدا كما يوجد داخل موقع العاب
    العاب بنات باقة رائعة من اجمل العاب
    بنات المكياج المميزة ووضع المكياج علي الفتيات كذلك سيتم توفير داخل موقعنا باقة رائعة ايضا من العاب الطبخ فكما اخبرتكم من قبل سوف يوجد عدة
    اقسام داخل الموقع بجانب قسم العاب تلبيس بنات والتي سوف تجدوها موجودة داخل الموقع تباعا مع الوقت الموقع في مرحلة وضع الالعاب كما يمكنكي
    سيدتي طلب اي لعبة داخل الموقع عن طريق نموذج اتصل بنا وسيتم الرد فورا وتحميل اللعبة المراد والتي تم طلبها من قبلكم واخيرا اتمني ان ينال موقع
    العاب رضاكم كما يوجد بالموقع
    عدة مشرفين علي اعلي مستوي يعملون بكل طاقتهم من اجل موقع افضل ومن اجل ارضاء جميع الزوار اخيرا وليس بأخر اتمني مشاركة الموقع مع
    اصدقائكم تدعيما منم لتقديم مستوي افضل كان معكم مدير موقع العاب بنات الموقع العربي الافضل
    في مجال تلبيس البنات

  47. Your article is awesome! How long does it take to complete this article? I have read through other blogs, but they are cumbersome and confusing. I hope you continue to have such quality articles to share with everyone! I believe there will be many people who share my views when they read this article from you!
    vex 3

  48. Our workplace is opened 24/7. So, you will be able to be aware U.S.A. All time giving you the best services with 100 percent pride inner terribly short quantity.
    24 hour check cashing Bridgeport

  49. This blog is so nice to me. I will continue to come here again and again. Visit my link as well. Good luck obat aborsi cara menggugurkan kandungan cara menggugurkan kandungan obat penggugur kandungan tanda tanda kehamilan cara menggugurkan kandungan obat aborsi obat telat datang bulan jual obat aborsi

  50. Thank you for such a sweet tutorial - all this time later, I've found it and love the end result. I appreciate the time you spent sharing your skills.

  51. Have you been seeking to ways to gain worldwide popularity shortly? You just will need to Buy Facebook Followers to become well known on web. buy followers on facebook

  52. I was very impressed by this post, this site has always been pleasant news. Thank you very much for such an interesting post. Keep working, great job! In my free time, I like play game: What about you?

  53. This is great, That's a great website, it really is what I was looking for, thank you for sharing!
    ymail login | ymail sign in |hotmail sign up |hotmail login

  54. Thanks for information provides of verified article post compare to save money & select the best amazing know more about this website visit # Cheapest Packers

    Packers and Movers in Delhi | Packers and Movers in Noida | Packers and Movers in Faridabad | Packers and Movers in Ghaziabad |Packers and Movers in Guwahati, this online directory helps you with Find Best Household Shifting, Office Relocation Tips, Relocation Tips, Car Transport Services, Corporate Relocation, Packing Tips, get free quotes at affordable Price.


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.