| «« Automatic Object Test Generation | jid3rL Frame Storage Types »» |
|
About
I'm Ryan Lowe, a Software Engineering graduate living in Ottawa, Canada. I like agile software development and Ruby on Rails.
I write this blog in Canadian English and don't use a spell checker. Typos happen.
Projects
» Full-time Ruby on Rails freelancer
» Full-time with Rails since May 2005 » Former committer for RadRails (now Aptana) » I also have a few Rails side-projects in development: 1. wheretogoinTO.com Toronto nightlife 2. Hey Heads Up! TODO list and sharing 3. Layered Genealogy family history research 4. foos for foosball scoring 5. fanconcert for music fans (on hold) Hiring Rails developers? I can telecommute by the hour from Ottawa, Canada »» Email: rails AT ryanlowe DOT ca
BulletBlog
Now hosted on Hey! Heads Up -- check it out!
Syndication
Pings
Recent
Derek Lowe's (Ryan's older brother) words at Ryan's funeral
blog@ryanlowe.ca no more Forging Email Headers: Good, Bad or Ugly? Sarcastic Dictionary (Part 1 of Many) Tags Hierarchies Twisting Rails is Risky Business Risky Business? My Take on Early Alphas Whoa, it's August 2007 Closing Comments A Postscript to "Growth at the grassroots" »» All Blog Posts
Linkage
del.icio.us/ryanlowe
technorati/ryanlowe.ca/blog Aurora Roy Jim Andrew Trasker Travis Kibbee Karen Dr. Unk Ayana Van Bloggers Joel Spolsky Robert Scoble Tim Bray Dave Winer Raymond Chen James Robertson Ruby/Rails Bloggers rubyonrails.org weblog David Heinemeier Hansson Dave Thomas James Duncan Davidson Mike Clark Jamis Buck Signal vs. Noise Tobias Luetke Amy Hoy: (24)slash7 Jeremy Voorhis Eclipse Bloggers Planet Eclipse EclipseZone Luis de la Rosa Eclipse Foundation Kim Horne Billy Biggs Ian Skerrett Mike Milinkovich Bjorn Freeman-Benson Denis Roy
Archives
|
id3v2 Frame Gigantism
Now that I'm done doing simple id3v2 tags with jid3v2, a small hurdle has come up. Images. Up until now, I've been storing the bytes of frames in byte arrays. When you get to images, which can be 100 kilobytes or more, then you start chewing up RAM with that kind of code. Images aren't the only frames with this problem. Technically in id3v2 the frames have very high length limits, which are specified in the frame header and differ by id3 version. 2.2 uses three bytes, 2.3 uses four bytes and 2.4 uses four sync-safe bytes. An effective library should be able to handle these limits.
**Note that the tag length is also a syncsafe 4 byte number (28 bits), which is the total length of all of the frames. So a frame with a length over 2^28 bytes isn't possible. Those are some big maximum frame sizes. The way I see it, I have two options for these large frames. The first is to make a copy of these long frames and store as files somewhere; maybe somewhere in the user's temp directory, maybe a directory that you specify to the library that's in your application's directory. Then if you need to write that frame to a tag, you copy that frame's file over to the new tag. An obvious disadvantage of this approach is that it takes time to copy bytes like this. The second option is to make a reference to the frame: the file, the starting position (offset) and the length. Then you don't have to copy the data in the frame to a temp directory in between. The disadvantage is that you can't move the source file, or the frame reference points to a missing file and the frame can't be written -- d'oh. This might make you question the lifecycle of a Last updated August 18, 2004 at 08:48 PM EST Comments
This is a tough one. Gonna have to think about this. » Posted by: roy at August 19, 2004 01:55 AMIf you get it working right, i'd love to start storing songs as metadata. » Posted by: Kibbee at August 19, 2004 07:34 AMwhat? Storing songs as metadata? Metadata for what? Do you want to describe a song with a song? » Posted by: Jim at August 19, 2004 08:33 AMHehe, yes I'm also confused. :) » Posted by: Ryan at August 19, 2004 08:56 AMEither way, it looks like a cap on frame sizes will have to be made. Maybe I'll only support frame sizes of 1 Megabyte as the default, which could be changed by a parameter. I'm hesitating about giving this library settings and "state", though. It just makes it that much more complicated. » Posted by: Ryan at August 19, 2004 09:11 AM
Now, if your own application were to move the files around - then it should clean up after itself and keep those references valid. » Posted by: dru at August 25, 2004 11:32 PMThe frame could move by as little as a byte by the time you read it as a file pointer and then use that file pointer. It could also disappear completely, so I have to recheck that it still exists. If it does, it can move and everything is still OK. The only problem with "cleaning up after myself" is that these files are in the wild -- not in a closed system. I can't control what other applications do with these tags, so I always have to assume the worst. I can't assume that a file and an offset will always be valid. » Posted by: Ryan at August 25, 2004 11:37 PM |