Breaking Eggs And Making Omelettes

A blog dealing with technical multimedia matters, binary reverse engineering, and the occasional video game hacking.

http://multimedia.cx/eggs/

Les articles publiés sur le site

  • Revisiting the Belco Alpha-400

    26 août 2010, par Multimedia MikeGeneral

    Relieved of the primary FATE maintenance duties, I decided to dust off my MIPS-based Belco Alpha-400 and try to get it doing FATE cycles. And just as I was about to get FATE running, I saw that Mans already got his MIPS-based Popcorn Hour device to run FATE. But here are my notes anyway.



    Getting A Prompt
    For my own benefit, I made a PDF to remind me precisely how to get a root prompt on the Alpha-400. The ‘jailbreak’ expression seems a little juvenile to me, but it seems to be in vogue right now.

    alpha-400-jailbreak.pdf

    Toolchain
    When I last tinkered with the Alpha-400, I was trying to build a toolchain that could build binaries to run on the unit’s MIPS chip, to no avail. Sometime last year, MichaelK put together x86_32-hosted toolchains that are able to build mipsel 32-bit binaries for Linux 2.4 and 2.6. The Alpha-400 uses a 2.4 kernel and the corresponding toolchain works famously for building current FFmpeg (--disable-devices is necessary for building).

    FATE Samples
    Next problem: Making the FATE suite available to the Alpha-400. I copied all of the FATE suite samples onto a VFAT-formatted SD card. The filename case is not preserved for all files which confounds me since it is preserved in other cases. I tried formatting the card for ext3 but the Alpha-400 would not mount it, even though /proc/filesystems lists ext3 (supporting an older version of ext3?).

    Alternative: Copy all of the FATE samples to the device’s rootfs. Space will be a little tight, though. Then again, there is over 600 MB of space free; I misread earlier and thought there were only 300 MB free.

    Remote Execution
    To perform FATE cycles on a remote device, it helps to be able to SSH into that remote device. I don’t even want to know how complicated it would be to build OpenSSH for the device. However, the last time I brought up this topic, I learned about a lighter weight SSH replacement called Dropbear. It turns out that Dropbear runs great on this MIPS computer.

    Running FATE Remotely
    I thought all the pieces would be in place to run FATE at this point. However, there is one more issue: Running FATE on a remote system requires that the host and the target are sharing a filesystem somehow. My personal favorite remote filesystem method is sshfs which is supposed to work wherever there is an SSH server. That’s not entirely true, though– sshfs also requires sftp-server to be installed on the server side, a program that Dropbear does not currently provide.

    I’m not even going to think about getting Samba or NFS server software installed on the Alpha-400. According to the unit’s /proc/filesystems file, nfs is a supported filesystem. I hate setting up NFS but may see if I can get that working anyway.

    Residual Weirdness
    The unit comes with the venerable Busybox program (BusyBox v1.4.1 (2007-06-01 20:37:18 CST) multi-call binary) for most of its standard command line utilities. I noticed a quirk where BusyBox’s md5sum gives weird hex characters. This might be a known/fixed issue.

    Another item is that the Alpha-400′s /dev/null file only has rwxr-xr-x per default. This caused trouble when I first tried to scp using Dropbear using a newly-created, unprivileged user.

  • ANSI FATE

    24 août 2010, par Multimedia MikeFATE Server

    The new FATE server is shaping up well. I think most of the old configurations have been migrated to the new server. I see one new compiler for x86_64– PathScale. It’s not faring particularly well at this point.

    New Tests
    As I write this, I noticed that there are now an even 700 tests, twice as many as the last time I trumpeted such a milestone. (It should be noted that the new FATE system finally breaks down the master regression suite into individual tests.) Thankfully, it’s no longer necessary to wait for me to create or edit tests (anyone with FFmpeg privileges can do this), nor is it necessary to keep up with this blog to know exactly what tests are new. Now, you can simply inspect the file history on tests/fate.mak and tests/fate2.mak (I think these 2 files are going to merge in the near future).

    Vitor, as of r24865: “Add FATE test for ANSI/ASCII animation and TTY demuxer.” Eh? What’s this about? I admit I was completely removed from FFmpeg development for much of June and July so I could have missed a lot. Fortunately, I can check the file history to see which lines were added to make this test happen. And if FATE is exercising the test, you know exactly where the samples will live. Here’s this new decoder in action on the relevant sample:



    The file history fingers Suxen drol/Peter Ross for this handiwork. I might have guessed– the only person who is arguably more enamored with old, weird formats than even I. Now we wait for the day that YouTube has support for this format. I’m sure there are huge archives of these animations out there (and I wager that Trixter and Jason Scott know where).



    It’s an animation — it just keeps going

    Meanwhile, the FATE suite now encompasses a bunch of perceptual audio formats, thanks to the 1-off testing method and a few other techniques. These formats include Bink audio, WMA Pro, WMA voice, Vorbis, ATRAC1, ATRAC3, MS-GSM, AC3, E-AC3, NellyMoser, TrueSpeech, Intel Music Coder, QDM2, RealAudio Cooker, QCELP (just going down the source control log here), and others, no doubt.

    Then there’s this curious tidbit: “Add FATE test for WMV8 DRM”. The test spec is "fate-wmv8-drm: CMD = framecrc -cryptokey 137381538c84c068111902a59c5cf6c340247c39 -i $(SAMPLES)/wmv8/wmv_drm.wmv -an". I would still like to investigate FFmpeg’s cryptographic capabilities, which I suspect are moving in a direction to function as a complete SSL stack one day.

    New Platforms
    As for new platforms, the new FATE system finally allows testing on OS/2 (remember that classic? It was “the totally cool way to run your computer”). Thanks to Dave Yeo for taking this on.

    Further, a new MIPS-based platform recently appeared on the FATE list. This one reports itself as running on 74kf CPU. Googling for this processor quickly brings up Mans’ post about the Popcorn Hour device. So, congratulations to him for getting the mundane box to serve a higher purpose. Perhaps one day, I’ll be able to do the same for that Belco Alpha-400 netbook.

  • FFmpeg and Code Coverage Tools

    21 août 2010, par Multimedia MikeFATE Server, Python

    Code coverage tools likely occupy the same niche as profiling tools: Tools that you're supposed to use somewhere during the software engineering process but probably never quite get around to it, usually because you're too busy adding features or fixing bugs. But there may come a day when you wish to learn how much of your code is actually being exercised in normal production use. For example, the team charged with continuously testing the FFmpeg project, would be curious to know how much code is being exercised, especially since many of the FATE test specs explicitly claim to be "exercising XYZ subsystem".

    The primary GNU code coverage tool is called gcov and is probably already on your GNU-based development system. I set out to determine how much FFmpeg source code is exercised while running the full FATE suite. I ran into some problems when trying to use gcov on a project-wide scale. I spackled around those holes with some very ad-hoc solutions. I'm sure I was just overlooking some more obvious solutions about which you all will be happy to enlighten me.

    Results
    I've learned to cut to the chase earlier in blog posts (results first, methods second). With that, here are the results I produced from this experiment. This Google spreadsheet contains 3 sheets: The first contains code coverage stats for a bunch of FFmpeg C files sorted first by percent coverage (ascending), then by number of lines (descending), thus highlighting which files have the most uncovered code (ffserver.c currently tops that chart). The second sheet has files for which no stats were generated. The third sheet has "problems". These files were rejected by my ad-hoc script.

    Here's a link to the data in CSV if you want to play with it yourself.

    Using gcov with FFmpeg
    To instrument a program for gcov analysis, compile and link the target program with the -fprofile-arcs and -ftest-coverage options. These need to be applied at both the compile and link stages, so in the case of FFmpeg, configure with:

      ./configure \
        --extra-cflags="-fprofile-arcs -ftest-coverage" \
        --extra-ldflags="-fprofile-arcs -ftest-coverage"
    

    The building process results in a bunch of .gcno files which pertain to code coverage. After running the program as normal, a bunch of .gcda files are generated. To get coverage statistics from these files, run 'gcov sourcefile.c'. This will print some basic statistics as well as generate a corresponding .gcov file with more detailed information about exactly which lines have been executed, and how many times.

    Be advised that the source file must either live in the same directory from which gcov is invoked, or else the path to the source must be given to gcov via the '-o, --object-directory' option.

    Resetting Statistics
    Statistics in the .gcda are cumulative. Should you wish to reset the statistics, doing this in the build directory should suffice:

      find . -name "*.gcda" | xargs rm -f
    

    Getting Project-Wide Data
    As mentioned, I had to get a little creative here to get a big picture of FFmpeg code coverage. After building FFmpeg with the code coverage options and running FATE,

    for file in `find . -name "*.c"` \
    do \
      echo "*****" $file \
      gcov -o `dirname $file` `basename $file` \
    done > ffmpeg-code-coverage.txt 2>&1
    

    After that, I ran the ffmpeg-code-coverage.txt file through a custom Python script to print out the 3 CSV files that I later dumped into the Google Spreadsheet.

    Further Work
    I'm sure there are better ways to do this, and I'm sure you all will let me know what they are. But I have to get the ball rolling somehow.

    There's also TestCocoon. I'd like to try that program and see if it addresses some of gcov's shortcomings (assuming they are indeed shortcomings rather than oversights).

    Source for script: process-gcov-slop.py

    PYTHON:
    1. #!/usr/bin/python
    2.  
    3. import re
    4.  
    5. lines = open("ffmpeg-code-coverage.txt").read().splitlines()
    6. no_coverage = ""
    7. coverage = "filename, % covered, total lines\n"
    8. problems = ""
    9.  
    10. stats_exp = re.compile('Lines executed:(\d+\.\d+)% of (\d+)')
    11. for i in xrange(len(lines)):
    12.     line = lines[i]
    13.     if line.startswith("***** "):
    14.         filename = line[line.find('./')+2:]
    15.         i += 1
    16.         if lines[i].find(":cannot open graph file") != -1:
    17.             no_coverage += filename + '\n'
    18.         else:
    19.             while lines[i].find(filename) == -1 and not lines[i].startswith("***** "):
    20.                 i += 1
    21.             try:
    22.                 (percent, total_lines) = stats_exp.findall(lines[i+1])[0]
    23.                 coverage += filename + ', ' + percent + ', ' + total_lines + '\n'
    24.             except IndexError:
    25.                 problems += filename + '\n'
    26.  
    27. open("no_coverage.csv", 'w').write(no_coverage)
    28. open("coverage.csv", 'w').write(coverage)
    29. open("problems.csv", 'w').write(problems)

  • Museum of Multimedia Software, Part 4

    20 août 2010, par Multimedia MikeSoftware Museum

    This is the last part of the series, at least until some more multimedia software shows up at my favorite thrift shop or the other boneyards I scavenge.

    Miscellaneous Multimedia Programs
    This set includes the titles Matinee FMV Screensaver, MetaCreations Painter Classic, and Multimedia JumpStart. The second one is likely a creation program. I have no idea what the third one is, while the first title gives me chills just thinking about the implications.



    Miscellaneous Creativity Software
    Magic Theatre and Microsoft Home: Creative Writer. I think I loaded up the former once to find a very basic animation program. The latter isn't necessarily multimedia-related but certainly classifies as creative software. It also reminds me of the ad I once spied in Entertainment Weekly magazine during the mid-1990s for a Microsoft music history CD-ROM. MS branched out into all kinds of niches.



    More Multimedia Creativity Software
    VideoCraft and U-Create Games & Animation. I wager these would be fun to play around with if I had the time.



    Showcase CD-ROMs
    "What Can You Make? Showcase 7" from Macromedia and Microsoft Multimedia Pack 10.



    Basic Multimedia Software Discs
    As a multimedia nerd, these Apple QuickTime and Microsoft Video for Windows discs make me sentimental.



    Real Software Collection
    Grit your teeth and gaze upon CD-ROM distributions of Real's software. There is a RealAudio disc back from when Real still called themselves Progressive Networks. "Everything you need to hear the web roar!"



    Clips
    And a few multimedia clip CD-ROMs, along with a disc that promises to test and tune your MPC setup.



    Wrap-Up
    I would be remiss if I neglected to mention a few more pieces of multimedia creation software in my collection. First, there's the Barbie Storymaker. I actually gave that one a go, as you can tragically see from that link. Further, the Taco Bell fast food restaurant chain ran, as one of their many kids meal promotions, a series of 4 simple Comics Constructor CD-ROMs. I played briefly with it here and again during an exploration of XML data formats and the parsing thereof (which the software uses).

  • Museum of Multimedia Software, Part 3

    18 août 2010, par Multimedia MikeSoftware Museum

    Discreet Cleaner 5
    Capture, author, encode, and publish multimedia in Real, QuickTime, Windows Media, MP3, DV, and MPEG formats. This package has a copyright date of 2001 (thus predating Flash video by a few years). This software seems to have since been purchased by Autodesk and is up to version 6.5 (which does support Flash video).



    Discreet Plasma
    "Web 3D Design." Package is copyright 2002. Like the last package, this package also makes reference to Discreet being a division of Autodesk. Sure enough, Autodesk purchased them in 1999 and would later rename them Autodesk Media and Entertainment.



    Debabelizer
    "The Graphics Processing Toolbox." Looking down its list of features on the box copy, I honestly wonder if it can accomplish anything that ImageMagick can't.



    MatchWare Mediator 7
    "Create Flash, HTML & CD-Rom Presentations." Wow, version 7, and with a latest copyright date of 2002 on the box. There's still a top-Google-hit web page for MatchWare Mediator 9, this one instead emphasizing interactive CDs, HTML, and then Flash.



    Final Cut Pro v1.2.5
    Promotional copy Apple's video editing software. No copyright date, but it requires a PowerPC G3 or G4 and Mac OS 9.



    Apple Keynote
    More Apple software that I think can technically be classified as multimedia-related. I'm not sure which version this is.