Help with uuencoded data

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Help with uuencoded data

Post by sakya »

Hi! :)

This question is not really psp related...but I try to ask. ;)

In OGG Vorbis and FLAC you can add the cover art and this will be saved in a comment named COVERART_UUENCODED.
I'm trying to retrieve the cover art but it seems I'm unable to do it.

I found no documentation on the web, but (from the name) I guess the string is uuencoded.
I tried to uudecode the data with this function that gets 4 encoded chars and outputs the corresponding 3 decoded chars (at least I think so):

Code: Select all

/* single-character decode */
#define DEC(c)	(((c) - ' ') & 077)

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// UUDECODE: decodes a group of 4 characters (outputs 3 characters)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void uudecode(char *encoded, char *decoded, int outCharNumber){
    int c1 = 0;
    int c2 = 0;
    int c3 = 0;

	c1 = DEC&#40;*encoded&#41; << 2 | DEC&#40;encoded&#91;1&#93;&#41; >> 4;
	c2 = DEC&#40;encoded&#91;1&#93;&#41; << 4 | DEC&#40;encoded&#91;2&#93;&#41; >> 2;
	c3 = DEC&#40;encoded&#91;2&#93;&#41; << 6 | DEC&#40;encoded&#91;3&#93;&#41;;
	if &#40;outCharNumber >= 1&#41;
    	decoded&#91;0&#93; = c1;
	if &#40;outCharNumber >= 2&#41;
    	decoded&#91;1&#93; = c2;
	if &#40;outCharNumber >= 3&#41;
    	decoded&#91;2&#93; = c3;
	decoded&#91;3&#93; = '\0';
&#125;
I tried to write to a file the decoded data but I don't obtain a valid jpeg file.
Can someone help me decoding this data, please? :)

Here you can download the encoded data and my "decoded" data.
http://upload2.net/page/download/EsH7bk ... t.rar.html

Many thanks
Ciaooo
Sakya
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Your "encoded" data isn't just plain uuencode, it has NULL bytes.
What tool are you using to embed the coverart? Just check the source for that.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

As I understand it, it's base64 encoded, not uuencoded. From RFC2045:

Code: Select all

                    Table 1&#58; The Base64 Alphabet

     Value Encoding  Value Encoding  Value Encoding  Value Encoding
         0 A            17 R            34 i            51 z
         1 B            18 S            35 j            52 0
         2 C            19 T            36 k            53 1
         3 D            20 U            37 l            54 2
         4 E            21 V            38 m            55 3
         5 F            22 W            39 n            56 4
         6 G            23 X            40 o            57 5
         7 H            24 Y            41 p            58 6
         8 I            25 Z            42 q            59 7
         9 J            26 a            43 r            60 8
        10 K            27 b            44 s            61 9
        11 L            28 c            45 t            62 +
        12 M            29 d            46 u            63 /
        13 N            30 e            47 v
        14 O            31 f            48 w         &#40;pad&#41; =
        15 P            32 g            49 x
        16 Q            33 h            50 y

   The encoded output stream must be represented in lines of no more
   than 76 characters each.  All line breaks or other characters not
   found in Table 1 must be ignored by decoding software.  In base64
   data, characters other than those in Table 1, line breaks, and other
   white space probably indicate a transmission error, about which a
   warning message or even a message rejection might be appropriate
   under some circumstances.
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)
jimparis wrote:Your "encoded" data isn't just plain uuencode, it has NULL bytes.
What tool are you using to embed the coverart? Just check the source for that.
I have no source of the tool I used...
Ok, I'll try base64.

Many thanks for your help. :)
Ciaooo
Sakya
Post Reply