0

I'm trying to build up a packet (adaption field)

enter image description here

I'm trying to build the PCR packet, but im a bit confused on python bitwise operators....

adapt_header_3 = (0x1f45db5e4df << (9 + 6)) # adapt_header_3 = 2149055849695

# d5 7d 51 05 7f 27 - This is what the correct result should look like


print(hex(adapt_header_3)) ## << but im getting this for adapt_header_3 0xfa2edaf26f8000

So I expect:

d5 7d 51 05 7f 27 (6 bytes)

But i'm getting:

fa 2e da f2 6f 80 00 00 (8 bytes)

UPDATE: Bit more of a test im using this:

adapt_header_1 = 0x7 
adapt_header_2 = 0x10
adapt_header_3 = 0x1f45db5e4df


adapt_header = 0x0
adapt_header = adapt_header | (adapt_header_1 << (48 + 8))
adapt_header = adapt_header | (adapt_header_2 << (48))
adapt_header = adapt_header | (adapt_header_3 << (9 + 6)) 

print(hex(adapt_header))

To build this:

enter image description here

Neil Bernard
  • 131
  • 2
  • 9
  • `0x1f45db5e4df` is already 2149055849695; if you're left-shifting it by 15 bits, it surely will be quite a bit larger after that. I'm not sure why you have a comment stating "adapt_header_3 = 2149055849695" on the first line. – 9769953 Nov 01 '19 at 11:12
  • Hi yes so so much for responding... I understand that 0x1f45db5e4df is already 2149055849695 but i'm trying to build an 8 byte packet.... ive annotated a drawing to explain above. The comment was just to represent the decimal so that I could remember the number :) – Neil Bernard Nov 01 '19 at 13:04
  • It is unclear how you arrived at the desired value. The PCR description says the value is `base * 300 + extension`. What is your base? What is your extension? – Lesiak Nov 01 '19 at 13:16
  • I still don't understand why you think that left-shifting a number 15 bits should result in a *smaller* number than the initial number. `2149055849695 * 2**15` is clearly larger than `234734206943015` (`0xd57d51057f27`). – 9769953 Nov 01 '19 at 13:21
  • If you arrive at that number because you're seeing it in some hex dump, perhaps you're simply looking at the wrong place, and consequently, your expectations for the correct value are wrong. – 9769953 Nov 01 '19 at 13:22
  • hi @Lesiak / @0 0 , i haven't done the calc yet because i wanted to get this working. Im currently pulling this info form a hex dump for comparison.... Pretty sure im looking in the right place.... – Neil Bernard Nov 01 '19 at 13:29
  • ahhhh right i see, the valure is caluclated in wireshark...... your right.... might need to do this.....https://stackoverflow.com/questions/29245281/extract-pcr-time-value-from-mpeg-ts hopefully my very poor maths will be up to it :) – Neil Bernard Nov 01 '19 at 14:16
  • Ok sorry I get it now... If anyone has any python psdedocode how I might be able to generate a rought 90khz prc clock for generating test packets that would be great, otherwsie ill figure it out in time :) – Neil Bernard Nov 01 '19 at 16:09
  • I’m sure you’ll find the answer on this post useful: https://stackoverflow.com/questions/58716586/how-to-generate-timestamps-from-pcr-in-hex – Baba.S Nov 05 '19 at 22:48

0 Answers0