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.
"I'd rather go naked than blow up my ass"

In reply to Re^3: encoding hdmi video byte by BrowserUk
in thread encoding hdmi video byte by hdmiguru

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.