October 2008 Archives

C++0x is now feature complete

Herb Sut­ter posts to tell us C++0x is now fea­ture com­plete. There will now be about a year of bug­fix­ing and clar­i­fi­ca­tion, but that’s it: all the fea­tures are now known, and their in­ter­faces are solid bar­ring any bugs being found. This means com­pil­ers can fi­nally start im­ple­ment­ing C++0x at full speed with­out too much worry of sur­prises.

The Com­mit­tee Draft is not yet avail­able, but it is about the same as the Sep­tem­ber 2008 Work­ing Draft.

Visual Studio 2010 CTP now available

Co­in­cid­ing with the 2008 PDC, the first Vi­sual Stu­dio 2010 CTP is now avail­able for down­load. At first glance, it in­cludes a few in­ter­est­ing things for C++:

I’ll be post­ing more as I take a closer look at these and other fea­tures.

Re-encoding VFR Anime

So I pre­ordered a Pan­dora, and for the past week have been re-en­cod­ing videos and music for play­ing on it. All goes well, until I dis­cov­ered my fa­vorite anime uses VFR—Vari­able Frame Rate. This is usu­ally only seen in anime, which tends to use a low frame rate for slow scenes and a higher frame rate for ac­tion se­quences and 3D ren­ders.

For what­ever rea­son, all the major video tools are com­pletely dumb when it comes to VFR. They ex­pect a con­stant fram­er­ate and will com­pletely screw up any­thing VFR. This is such a prob­lem that many raw and fan­sub groups tend to give up and dec­i­mate their en­codes to a con­stant 24fps, not­i­ca­bly sac­ri­fic­ing qual­ity.

But there is a light at the end of the tun­nel. After sev­eral days of search­ing and tin­ker­ing, I’ve found out how to do it. Here are the steps I’m using—they are def­i­nitely still not op­ti­mal (though it does pro­duce a per­fect en­code) so if you know of any­thing bet­ter, let me know.

  1. If your source is not MKV, you’ll need to con­vert it. This can be done using mkvmerge from the MKV­Tool­nix pack­age.
  2. En­code the source like nor­mal with x264.
  3. Use the mkv2vfr util­ity from the Haali Media Split­ter pack­age to ex­tract a time­code file from the source MKV. This is the im­por­tant step—the time­code file de­scribes the FPS that dif­fer­ent seg­ments of your video run at. The mkvex­tract pro­gram from MKV­Tool­nix has a time­code ex­trac­tion op­tion that looks cleaner, but seems to pro­duce an in­com­pat­i­ble or bro­ken time­code file.
  4. Mux the new video with the time­code file and the audio. This is also done with mkvmerge. Make sure you spec­ify the time­code file for the video, not the audio.

Here are the exact com­mands I used:

# 1. Convert MP4 to MKV
mkvmerge -o "source.mkv" -a 2 -d 1 -S "source.mp4" --track-order 0:1,0:2

# 2. Encode
x264 --crf 26 --ref 8 --mixed-refs --bframes 16 --b-pyramid
     --direct auto --filter 1:1 --subme 7 --trellis 2 --psy-rd 0.6:0
     --partitions p8x8,b8x8,i4x4,i8x8 --8x8dct --vbv-maxrate 25000
     --me umh --threads auto --thread-input --aq-mode 0
     --progress --no-psnr --no-ssim --output "output.mkv" "source.avs"

# 3. Extract timecodes
mkv2vfr "source.mkv" "dummy.avi" "timecodes.txt"

# 4. Mux output with timecodes and original audio.
mkvmerge -o "muxed.mkv" --timecodes "1:timecodes.txt"
         -d 1 -A -S "output.mkv" -a 2 -D -S "source.mkv"
         --track-order 0:1,1:2

With source.​avs look­ing like:

DirectShowSource("source.mkv", audio=false)

crop(2, 0, -4, -2)
Spline36Resize(800, 432)

vecs = last.MVAnalyseMulti(refframes=2, idx=1)
last.MVDegrainMulti(vecs, idx=1)

Automatic hyphenation

I’ve just in­stalled Hy­phen­ator—a re­ally cool script which au­to­mat­i­cally adds soft hy­phens to words, which means I can fi­nally jus­tify text. If you’ve got Javascript turned on, you should see nice hy­phen­ated line wrap­ping in ad­di­tion to syn­tax high­light­ing on code.