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



87 comments:

  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! (http://www.spotsoftware.nl/bitmap.html) :)

    ReplyDelete
  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.

    ReplyDelete
  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?

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

    ReplyDelete
  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.

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

    ReplyDelete
  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.

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

    ReplyDelete
  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

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

    ReplyDelete
  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

    ReplyDelete
  12. First You got a great blog.I will be interested in more similar topics.
    Signature:
    happy wheels
    friv
    girlsgogames
    games2girls
    happy wheels

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

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

    ReplyDelete
  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

    ReplyDelete
  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 | Slither.io

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

    ReplyDelete
  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

    ReplyDelete
  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 |

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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.
    wings.io l wingsio l wings io l wingsio game l play wingsio

    ReplyDelete


  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

    ReplyDelete
  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

    ReplyDelete
  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?

    ReplyDelete
  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

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

    ReplyDelete
  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

    ReplyDelete
  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!
    abcya

    ReplyDelete
  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

    ReplyDelete
  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.
    http://fivenightsatfreddysplay.com

    ReplyDelete
  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

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

    lennyfacetext.com

    ReplyDelete
  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 ,

    ReplyDelete
  45. تخلص من جميع مشاكل الحشرات في شركة مكافحة حشرات لدينا ابادة حشرات للمولات وخدمات متخصصة للاماكن العامة والواسعه ابادة حشرات للمصانع وتخفيضات هائلة في ابادة حشرات للمطاعم ومبيدات متخصصة من افضل الانواع في مكافحة حشرات للجناين موقعنا:
    http://www.anti-insects.com/%D8%B4%D8%B1%D9%83%D8%A9-%D8%A7%D9%84%D9%85%D8%B5%D8%A7%D9%86%D8%B9-%D8%A7%D9%84%D9%85%D8%B7%D8%A7%D8%B9%D9%85-%D8%A7%D9%84%D9%85%D9%88%D9%84%D8%A7%D8%AA-%D8%AC%D9%86%D8%A7%D9%8A%D9%86/

    ReplyDelete

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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  49. This blog is so nice to me. I will continue to come here again and again. Visit my link as well. Good luck
    http://www.jualobataborsiherbal.com/ obat aborsi
    http://caramenggugurkankandungan.info/ cara menggugurkan kandungan
    http://www.jualobataborsiherbal.com/cara-menggugurkan-kandungan/ cara menggugurkan kandungan
    http://jualobatpenggugurkandungan.net/ obat penggugur kandungan
    http://tandatandakehamilan.net/ tanda tanda kehamilan
    http://tandatandakehamilan.net/cara-cepat-dan-selamat-menggugurkan-kandungan/ cara menggugurkan kandungan
    http://obataborsi59.com/ obat aborsi
    http://obattelatdatangbulan.info/ obat telat datang bulan
    http://klinikobataborsi.com/ jual obat aborsi

    ReplyDelete
  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.
    www.appbaixar.com

    ReplyDelete
  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

    ReplyDelete
  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: vex3game.com. What about you?

    ReplyDelete
  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

    ReplyDelete
  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.

    ReplyDelete
  55. I appreciate it!. I really like it when people get together and share ideas. Great website, continue the good work!. Either way, great web and I look forward to seeing it grow over time. Thank you so much.
    super smash flash 2

    ReplyDelete
  56. Even those banks that lend money bills you a really high rate of curiosity
    Edirne Demirdöküm Servisi secured lenders
    will most likely process your loan application as quickly as is possible.
    items others"cutting edge modern society this time around,Beats Beats Dr Dre Online Dr Dre Online, They provide a multi functional great answer to Dre Beats Dre the problem as well as boredom,Dre Beats Dre, So,Best Coffee Makers, Toy grade trucks are..

    ReplyDelete
  57. Your blog posts are more interesting and impressive. I think there are many people like and visit it regularly, including me.I actually appreciate your own position and I will be sure to come back here.
    brtaram

    ReplyDelete
  58. I appreciate it!. I really like it when people get together and share ideas. Great website, continue the good work!. Either way, great web and I look forward to seeing it grow over time. Thank you so much.
    super smash flash 2

    ReplyDelete
  59. This solution is the most effective medium that you could choose improving net traffic on your web page as all the people will have the ability to see the products and also solutions that you are offering. buy real usa facebook likes

    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.