Javascript to work around CSS limitation: expand to container width 
Sunday, September 14, 2008, 06:47 PM - Web
Having a line of text which is as wide as its container width, sound simple? Well, actually it is not that easy.

For my pic a day gallery I wanted to put a navigation interface under the thumbnails, and to have this navigation interface extend to the full possible width. Of course, as the width changes according to the browser window, it can not be specified in pixels.

A possibility would be to use a single row table, and to put each navigation element within an individual table cell, but first it is far from an elegant solution, second I did not thought about this possibility when doing the navigation interface.

As the navigation interface is made from text elements, I thought about simply using the text-align: justify CSS property. However, this doesn't justify the last line of a paragraph, and in my case the navigation interface is a single line. CSS3 is supposed to address this issue, by the text-align-last property, which allows to set justification method for the last line of a paragraph. Problem: it is not yet supported by browsers.

So here is the trick: using Javascript to increase spacing between words, until it fills the whole container width.
First, set a small words spacing, then iteratively increase it. While doing this, check the element height. When the height increase, it means that your text was wrapped over a new line. You can then roll back words by one step, and you are done: your line now fills the whole width:

function expandNavigation() {
document.getElementById('config').style.opacity = 0;
navi = document.getElementById('navigation'); = 0;
var h0 = navi.scrollHeight;
var em = 0.2;
var em_inc = 0.2;

do {
em += em_inc; = em + 'em';
} while (navi.scrollHeight == h0)
em -= em_inc; = em + 'em';

fadeIn('navigation', 0, 15);
fadeIn('config', 0, 15);

In order to avoid flickering while the word spacing is increased, I also hid the text while iterating, and only made it visible again at when the optimal word spacing is found (the function fadeIn sets the text back to its visible state).
  |  0 trackbacks   |  permalink   |  related link

Servicing a Pentacon 50/1.8 
Wednesday, August 27, 2008, 08:08 PM - Servicing
I had this "Pentacon auto 50/1.8 multicoated" m42 lens lying in bad shape since a few monthes ago(front part going away from rear part). I finally toke some time to fix it, so here is my small repair guide.

First, unscrew the front ring with the markings on it. It is just a plastic ring that is screwed (by the way, it looks really cheap compared to other parts). If you are lucky, you will be easily able to unscrew it, if not you will probably need to use a rubber ring or something similar to improve your grip while unscrewing it.

Now, remove the thin screw from the inner ring.

You can now unscrew the outer inner ring. I used some spanners, but you can probably also use some screwdrivers.

You can now access the front part of the optical elements, and unscrew them. If you unscrew the outer ring with the two tabs they will come in one single piece, if you unscrew the inner ring with the two tabs they will come into two pieces.

You can now see the front of the diaphragm.

By the way, if you only need to adjust infinity focus, there is no need to remove any optical element. Once you removed the front rings, you should see three big screws. Those are used to adjust infinity (more about this in a few steps).

In my case, as the front part was loose, I had to go further. Now, let's look at the rear part. Remove the three rear screws, and you can remove the rear part (mount and aperture ring).

Unscrew the optical barrel, and you should now have this part:

If your lens is in correct shape, you will perhaps not be able to remove the optical barrel yet because a metal cam is blocking it.

Beware not to loose the small bearing which is used for the M/A switch. I would suggest you to remove it and to only put it back when reassembling the lens.

Remove the two screws which hold the can.

After removing this cam, you should be able to remove the optical barrel (if not yet done). If you need to replace the grease from the helicoid, it's the right time to do it. Under the cam, there is yet another bearing along with a small spring.

As with the previous one, I would suggest you to remove the bearing and to only put it back when doing the final reassembly of the lens. If you loose it, you will have a working but stepless aperture ring.
Reassembling is "just" a matter of putting everything back. The only thing that should take a bit of time is readjusting infitity focus.
A bit of explanation about this: when focusing toward infinity, the optical block goes toward the rear of the lens, and when focusing toward close distance the optical block goes toward the front of the lens. The optical block is held inside the helicoid by the metal cam we removed. When adjusting the focus, if you close focus but the optical block is not properly adjusted, if will move too far from the rear of the lens, and will go out of the cam. You will hear a small clicking noise when it goes out because it will also go out of the diaphragm cam. If this happen, your only solution is to remove again the back of the lens, remove the metal cam, and reassemble everything. That is why I would suggest you to only check infinity (by screwing the three focus adjustment screws, checking infinity, unscrewing the screws, move the focus ring a bit, re-screw the 3 screws, and so on), and only when the infinity focus is fine, you will then be able to focus to the near postion without any issue.
  |  0 trackbacks   |  permalink   |  related link

Thursday, August 21, 2008, 04:20 PM - Audio coding
There is a lot of activity regarding AAC in FFMPEG since July.

The AAC decoder from Summer Of Code (SOC) 2006 is now included within the official FFMPEG tree, after cleanups by Robert Swain. It an AAC-LC and AAC-Main profiles decoder, so it can not yet replace FAAD/FAAD2 as it doesn't decode SBR and PS (used within HE-AAC and HE-AACv2), but it's a good step in the right direction. There is also an SBR decoder in the work, so we will perhaps see this in a few months.

On the encoder side, Konstantin Shishkov has been working on an AAC-LC encoder this summer. While it is not yet competitive with the best AAC-LC encoders, it already provides a good features set, and best of all, it features a psychoacoustic model (it should be the first psychoacoustic model to hit FFMPEG). The psy model is inspired from the 3GPP model, which is a stripped down encoder from Coding Technologies, provided with some basic documentation of the algorithms.
  |  0 trackbacks   |  permalink   |  related link

Partial servicing of Tamron Adaptall SP 60-300 
Friday, July 25, 2008, 06:22 PM - Servicing
I received a Tamron SP 60-300 lens which is in need of cleaning (fungus and grease on lens elements).
I did not yet had time to fully clean it, but here are the steps for a partial cleaning (front part of the lens).

Fold the top of the rubber grip:

With a permanent marker, put some kind of mark over both tape and metal, so you could later know what was the original position of elements:

Remove screws:

You are now able to slide down the zoom/focus ring:

(actually, it appeared that unscrewing the zoom/focus ring was not needed for the cleaning I have done)

Carefully peel the adhesive tape:

Unscrew the two new screws, and you are now able to remove the front part.

The lens now looks like this:

I was able to easily unscrew the central ring (the one just around the new apparent front glass element) and then this lens element can be removed to be cleaned. On my lens, what you see on the top left corner are some grease bubbles (now cleaned).

Tip: each time you remove an element, use a permanent marker to put a tiny mark on its side in order to know the front from the back side. It's really annoying when you remove a lens glass element, and after cleaning it you don't remember which side was up.
  |  0 trackbacks   |  permalink   |  related link

Back Next