in reply to Re: encoding hdmi video byte
in thread encoding hdmi video byte

I have to then add a bit 9 MSB indicating the encoding type which will be 1 in my case and then send these 10bits using 2byte packet. where 10bits will be taking LSb.

Replies are listed 'Best First'.
Re^3: encoding hdmi video byte
by BrowserUk (Patriarch) on Feb 24, 2010 at 19:25 UTC

    Well, the fastest way to make the basic conversion 8-bit to 8-bit (that 9th bit is always one according to your spec), is tr///; That does byte for byte translations on strings very quickly. (You'd need to unwrap the following):

    tr[\x00-\xff][ \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 \x00UT\x01P\x05\x04Q(\x15\x14)\x10ED\x11 ];

    The above would have to be coded as a single line as the look up tables are built at compile time. It makes it difficult to format it nicely. evaling a sub into existance at runtime is one possibility.

    But that is a very strange encoding process as there appears to be no way to reverse it! The 256 input bytes result in just 16 output values.

    Converting those encoded bytes to the 16-bit values with the two constant 1 bits set, is just a case of or-ing them with the appropriate 16-bit value, possible left shifting first. But the right combination of constant value and shifting will depend upon the endian-ness of the source and target machines and whether they are the same or different.

    When you say "send this 2 byte packet", do you mean the program doing the convertion will do the sending (via socket or port?). Or will you write the data to a file and then use another program to send it?

    If the latter, then yu can savce 50% of the disk space by writing the encoded 8-bit data to file, and adding the two constant bits in the program doing the sending.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Hi BrowserUK, Thanks for the reply. I am new to Perl and could not understand the code you posted. can you pls help in clarifying the code. Thanks for the other tips about reducing the file size. Thanks

        Read this and come back if you have specific questions.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.