YUV422 format & byte order

YUV422: 16 bits/pixel packed YUV format. Y is sampled at every pixel, U and V are sampled at every second pixel horizontally.
1. Three main formats (the illustration uses little endian?)
  • UYVY (Y422, UYNV, HDYC)
    • The difference between HDYC and others (UYVY, Y422, UYNV) is: the RGB space of HDYC is defined in BT.709, rather than BT470 series (the latest one: BT470.7)
    • Different RGB color spaces is distinguished by defining different values for three primary colors and a white point.
    • NTSC, PAL, SECAM follows BT470. HDTV follows BT.709.
  • YUY2
  • YVYU
    • just different byte ordering.
2. bits per channel: 8 bit, 16 bit or 10 bit
 10/16 bit YUV formats use a fixed-point representation for both the luma channel and the chroma channels. Sample values are scaled 8-bit values, using a scaling factor of 2^(n-8), when n = 10 or 16.
10-bit formats also use 16 bits for each channel, with the lowest 6 bits set to zero ((little endian in the graph below)
Diagram showing 10-bit representation
The precision conversions can be performed using simple bit shifts. E.g. If 8-bit value is 235, the corresponding 10-bit format is 235×4=940
3. Byte order/endianness
BT656 transmit order: U–Y–V–Y.
If the receiving hardware (especially DMA) is configured to use little endian, U/Cb will be written to the lowest byte, followed by Y, then V, then Y at the upper most byte.
If the receiving hardware only supports big endian, U will be written to the upper most byte, …with Y at the lowest byte.

Sleep functions

These functions are used to suspend a calling thread for a given length of time, until a signal is received (question: does delay() cares about signals?)
sleep(unsigned int seconds);
usleep(useconds_t useconds);
delay(unsigned int mseconds);
nanosleep(const struct timespec* rqtp, struct timespec* rmtp); // rqtp: requested time; rmtp: remaining time, can be NULL.
Note: the suspension time may be greater than the requested amount, due to the nature of time measurement, or the thread scheduling. Below is an example of usleep(500): 500us sleep turns to be 1ms 920us, or 1ms 853us.

if(delay_needed) {

int sleep_us = 500;

trace_logf( _NTO_TRACE_USERFIRST + 801, “delay %d us”, sleep_us);


delay_needed = 0;


trace_logf( _NTO_TRACE_USERFIRST + 800, “set up a new transfer”);

Screen shot 2015-05-07 at 4.54.22 PM Screen shot 2015-05-07 at 4.52.31 PM