Professional Web Applications Themes

Endian trouble reading file? - Mac Programming

I have a program that checks if a file is an MP3 by looking for the ID3 tag. After reading the ID3 specification, I wrote a program that seeks to the end of file and then moves back 128 bytes, the point where the tag should begin. Then I read 3 bytes (the "ID3" tag should be here). Instead of getting the tag, I get nothing. After some testing I found that the tag is actually at the beginning of the file,(offsets 0-2). So I'm thinking, Oh yes, there's the endian issue so things should be "flipped". But if thats ...

  1. #1

    Default Endian trouble reading file?

    I have a program that checks if a file is an MP3 by looking for the ID3
    tag. After reading the ID3 specification, I wrote a program that seeks
    to the end of file and then moves back 128 bytes, the point where the
    tag should begin. Then I read 3 bytes (the "ID3" tag should be here).
    Instead of getting the tag, I get nothing. After some testing I found
    that the tag is actually at the beginning of the file,(offsets 0-2). So
    I'm thinking, Oh yes, there's the endian issue so things should be
    "flipped". But if thats the case, shouldn't the tag be located at bytes
    125-127 and should be read in as "3DI"? I would think the Cocoa API's
    would "obscure" the endian issue such that reading a file like an MP3
    would behave according to its specification or am I missing something
    here?
    Thanks
    Lorenzo Guest

  2. #2

    Default Re: Endian trouble reading file?

    In article <thethurmans.com>,
    Lorenzo Thurman <com> wrote:
     

    1) Endian is not a byte-stream concept, so it has nothing to do with
    positions within the file. It has, rather, to do with how data stored
    in shorts, longs, floats, doubles, or Int64s are stored.

    2) The layout of an MP3 file is *much* more complex than just offsetting
    a certain number of bytes into the file.

    3) Quoting from the ID3 specification:
    "The bitorder in ID3v2 is most
    significant bit first (MSB). The
    byteorder in multibyte numbers is most significant byte first (e.g.
    $12345678 would be encoded $12 34 56 78), also known as big endian
    and network byte order." So there is no endian issue here.

    4) If there was an endian issue, you would resolve it in your code using
    the various Macros in Endian.h which are provided for helping you with
    just such a thing.

    5) No framework is going to handle things like this for you when it
    deals with low level structures such as files or memory buffers. This
    is because the system doesn't "know" about the structure of the buffers
    in question.

    -- Tom
    Tom Guest

  3. #3

    Default Re: Endian trouble reading file?


    "Lorenzo Thurman" <com> skrev i meddelandet
    news:thethurmans.com... 

    it's not a endian thing
    it's a ID3 v2 tag which are located in the beginning of an mp3 file

    more info here:
    http://www.id3.org/easy.html


     


    Rolf Guest

  4. #4

    Default Re: Endian trouble reading file?

    In article <WBr1c.51131$telia.net>,
    "Rolf Nilsson" <nu> wrote:
     
    >
    > it's not a endian thing
    > it's a ID3 v2 tag which are located in the beginning of an mp3 file
    >
    > more info here:
    > http://www.id3.org/easy.html
    >
    >

    >
    >[/ref]


    Thanks, apparently I have old doentation.
    Lorenzo Guest

  5. #5

    Default Re: Endian trouble reading file?

    Lorenzo Thurman <com> wrote:
     [/ref][/ref]
     

    Apparently also another wrong assumption: I think it is reasonable to
    expect there are MP3 files without ID3 tags, as ID3 became popular when
    the early adoptors couldnt handle their 'huge' MP3 CDs with 8.3
    ShrtNams.MP3.

    regards,
    Tom_E

    --
    This address is valid in its unmodified form but expires soon.

    Thomas Guest

Similar Threads

  1. Replies: 4
    Last Post: July 9th, 08:20 AM
  2. Replies: 2
    Last Post: May 15th, 09:36 AM
  3. Replies: 0
    Last Post: July 25th, 01:55 AM
  4. .Net webservice and java client little endian/big endian
    By pallavi in forum ASP.NET Web Services
    Replies: 0
    Last Post: April 5th, 07:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139