I need to extract some information from a Transport Stream like PID, PAT, PMT, etc.
I found an example code to get the PID:
pid = ((buf[1] << 8) | (buf[2] & 0xff)) & 0x1fff;
But I could not understand the reason to get the buf[1]
and shift 8 to the left side because to get the PID information I need get the 5 last bits from the buf[1]
and all 8 from the buf[2]
. I tested the code and the result was good. I just want to understand the mean of this first part: buf[1] << 8
in the equation. Could someone help me?