BSID Bug?

ATSC 3.0 Forum
drmpeg
Posts: 14
Joined: Mon Jan 23, 2023 6:34 pm
x 14

Re: BSID Bug?

Post by drmpeg »

Here's the C code.

https://github.com/drmpeg/dtv-utils/blo ... r/l1dump.c

Some examples.

Two PLPs with TDM.

Code: Select all

L1B_version = 0
L1B_mimo_scattered_pilot_encoding = Walsh-Hadamard pilots or no MIMO subframes
L1B_lls_flag = No LLS in current frame
L1B_time_info_flag = Time information is not included in the current frame
L1B_return_channel_flag = 0
L1B_papr_reduction = No PAPR reduction used
L1B_frame_length_mode = symbol-aligned
L1B_time_offset = 0
L1B_additional samples = 0
L1B_num_subframes = 1
L1B_preamble_num_symbols = 2
L1B_preamble_reduced_carriers = 5.832 MHz
L1B_L1_Detail_content_tag = 0
L1B_L1_Detail_size_bytes = 34
L1B_L1_Detail_fec_type = Mode 1
L1B_L1_additional_parity_mode = K=0 (No additional parity used)
L1B_L1_Detail_total_cells = 3223
L1B_first_sub_mimo = No MIMO
L1B_first_sub_miso = No MISO
L1B_first_sub_fft_size = 8K
L1B_first_sub_reduced_carriers = 5.832 MHz
L1B_first_sub_guard_interval = GI5_1024
L1B_first_sub_num_ofdm_symbols = 150
L1B_first_sub_scattered_pilot_pattern = SP3_4
L1B_first_sub_scattered_pilot_boost = 1.660
L1B_first_sub_sbs_first = not present
L1B_first_sub_sbs_last = present
L1B_crc = 0x00000000
L1D_version = 0
L1D_num_rf = No Channel Bonding
******** subframe = 0 ********
L1D_frequency_interleaver = All Symbols
L1D_sbs_null_cells = 3026
L1D_num_plp = 2
********** plp = 0 **********
L1D_plp0_id = 0
L1D_plp0_lls_flag = 0
L1D_plp0_layer = Core
L1D_plp0_start = 0
L1D_plp0_size = 453600
L1D_plp0_scrambler_type = PRBS
L1D_plp0_fec_type = BCH + 64K LDPC
L1D_plp0_mod = 16QAM
L1D_plp0_cod = 9/15
L1D_plp0_TI_mode = Hybrid time interleaving
L1D_plp0_type = non-dispersed
L1D_plp0_HTI_inter_subframe = 0
L1D_plp0_HTI_num_ti_blocks = 2
L1D_plp0_HTI_num_fec_blocks_max = 28
L1D_plp0_HTI_num_fec_blocks = 28
L1D_plp0_HTI_cell_interleaver = enabled
********** plp = 1 **********
L1D_plp1_id = 1
L1D_plp1_lls_flag = 0
L1D_plp1_layer = Core
L1D_plp1_start = 453600
L1D_plp1_size = 475200
L1D_plp1_scrambler_type = PRBS
L1D_plp1_fec_type = BCH + 64K LDPC
L1D_plp1_mod = 64QAM
L1D_plp1_cod = 9/15
L1D_plp1_TI_mode = Hybrid time interleaving
L1D_plp1_type = non-dispersed
L1D_plp1_HTI_inter_subframe = 0
L1D_plp1_HTI_num_ti_blocks = 2
L1D_plp1_HTI_num_fec_blocks_max = 44
L1D_plp1_HTI_num_fec_blocks = 44
L1D_plp1_HTI_cell_interleaver = enabled
L1D_crc = 0xcaa7774f
Two PLPs with LDM

Code: Select all

L1B_version = 0
L1B_mimo_scattered_pilot_encoding = Walsh-Hadamard pilots or no MIMO subframes
L1B_lls_flag = No LLS in current frame
L1B_time_info_flag = Time information is not included in the current frame
L1B_return_channel_flag = 0
L1B_papr_reduction = No PAPR reduction used
L1B_frame_length_mode = symbol-aligned
L1B_time_offset = 6656
L1B_additional samples = 0
L1B_num_subframes = 1
L1B_preamble_num_symbols = 1
L1B_L1_Detail_content_tag = 0
L1B_L1_Detail_size_bytes = 34
L1B_L1_Detail_fec_type = Mode 1
L1B_L1_additional_parity_mode = K=0 (No additional parity used)
L1B_L1_Detail_total_cells = 3223
L1B_first_sub_mimo = No MIMO
L1B_first_sub_miso = No MISO
L1B_first_sub_fft_size = 16K
L1B_first_sub_reduced_carriers = 5.832 MHz
L1B_first_sub_guard_interval = GI4_768
L1B_first_sub_num_ofdm_symbols = 108
L1B_first_sub_scattered_pilot_pattern = SP8_2
L1B_first_sub_scattered_pilot_boost = 1.841
L1B_first_sub_sbs_first = present
L1B_first_sub_sbs_last = present
L1B_crc = 0x00000000
L1D_version = 0
L1D_num_rf = No Channel Bonding
******** subframe = 0 ********
L1D_frequency_interleaver = All Symbols
L1D_sbs_null_cells = 2061
L1D_num_plp = 2
********** plp = 0 **********
L1D_plp0_id = 0
L1D_plp0_lls_flag = 1
L1D_plp0_layer = Core
L1D_plp0_start = 0
L1D_plp0_size = 1387647
L1D_plp0_scrambler_type = PRBS
L1D_plp0_fec_type = BCH + 64K LDPC
L1D_plp0_mod = QPSK
L1D_plp0_cod = 7/15
L1D_plp0_TI_mode = Convolutional time interleaving
L1D_plp0_CTI_fec_block_start = 109410
L1D_plp0_type = non-dispersed
L1D_plp0_TI_extended_interleaving = disabled
L1D_plp0_CTI_depth = 1024
L1D_plp0_CTI_start_row = 254
********** plp = 1 **********
L1D_plp1_id = 1
L1D_plp1_lls_flag = 1
L1D_plp1_layer = Enhanced
L1D_plp1_start = 0
L1D_plp1_size = 1387647
L1D_plp1_scrambler_type = PRBS
L1D_plp1_fec_type = BCH + 64K LDPC
L1D_plp1_mod = 64QAM
L1D_plp1_cod = 10/15
L1D_plp1_TI_mode = Convolutional time interleaving
L1D_plp1_CTI_fec_block_start = 573746
L1D_plp1_ldm_injection_level = 4.0 dB
L1D_crc = 0xbf0f60ff
Two sub-frames

Code: Select all

L1B_version = 0
L1B_mimo_scattered_pilot_encoding = Walsh-Hadamard pilots or no MIMO subframes
L1B_lls_flag = No LLS in current frame
L1B_time_info_flag = Time information is not included in the current frame
L1B_return_channel_flag = 0
L1B_papr_reduction = No PAPR reduction used
L1B_frame_length_mode = symbol-aligned
L1B_time_offset = 0
L1B_additional samples = 0
L1B_num_subframes = 2
L1B_preamble_num_symbols = 2
L1B_preamble_reduced_carriers = 5.832 MHz
L1B_L1_Detail_content_tag = 0
L1B_L1_Detail_size_bytes = 41
L1B_L1_Detail_fec_type = Mode 1
L1B_L1_additional_parity_mode = K=0 (No additional parity used)
L1B_L1_Detail_total_cells = 3563
L1B_first_sub_mimo = No MIMO
L1B_first_sub_miso = No MISO
L1B_first_sub_fft_size = 8K
L1B_first_sub_reduced_carriers = 5.832 MHz
L1B_first_sub_guard_interval = GI5_1024
L1B_first_sub_num_ofdm_symbols = 72
L1B_first_sub_scattered_pilot_pattern = SP3_4
L1B_first_sub_scattered_pilot_boost = 1.660
L1B_first_sub_sbs_first = not present
L1B_first_sub_sbs_last = present
L1B_crc = 0x00000000
L1D_version = 0
L1D_num_rf = No Channel Bonding
******** subframe = 0 ********
L1D_subframe_multiplex = 0
L1D_frequency_interleaver = All Symbols
L1D_sbs_null_cells = 3026
L1D_num_plp = 1
********** plp = 0 **********
L1D_plp0_id = 0
L1D_plp0_lls_flag = 0
L1D_plp0_layer = Core
L1D_plp0_start = 0
L1D_plp0_size = 442800
L1D_plp0_scrambler_type = PRBS
L1D_plp0_fec_type = BCH + 64K LDPC
L1D_plp0_mod = 64QAM
L1D_plp0_cod = 9/15
L1D_plp0_TI_mode = Hybrid time interleaving
L1D_plp0_type = non-dispersed
L1D_plp0_HTI_inter_subframe = 0
L1D_plp0_HTI_num_ti_blocks = 2
L1D_plp0_HTI_num_fec_blocks_max = 41
L1D_plp0_HTI_num_fec_blocks = 41
L1D_plp0_HTI_cell_interleaver = enabled
******** subframe = 1 ********
L1D_mimo = No MIMO
L1D_miso = No MISO
L1D_fft_size = 32K
L1D_reduced_carriers = 5.832 MHz
L1D_guard_interval = GI4_768
L1D_num_ofdm_symbols = 18
L1D_scattered_pilot_pattern = SP32_2
L1D_scattered_pilot_boost = 2.630
L1D_sbs_first = present
L1D_sbs_last = present
L1D_subframe_multiplex = 0
L1D_frequency_interleaver = All Symbols
L1D_sbs_null_cells = 2550
L1D_num_plp = 1
********** plp = 0 **********
L1D_plp0_id = 1
L1D_plp0_lls_flag = 0
L1D_plp0_layer = Core
L1D_plp0_start = 0
L1D_plp0_size = 477900
L1D_plp0_scrambler_type = PRBS
L1D_plp0_fec_type = BCH + 64K LDPC
L1D_plp0_mod = 256QAM
L1D_plp0_cod = 12/15
L1D_plp0_TI_mode = Hybrid time interleaving
L1D_plp0_type = non-dispersed
L1D_plp0_HTI_inter_subframe = 0
L1D_plp0_HTI_num_ti_blocks = 2
L1D_plp0_HTI_num_fec_blocks_max = 59
L1D_plp0_HTI_num_fec_blocks = 59
L1D_plp0_HTI_cell_interleaver = enabled
L1D_crc = 0x310d176f

drmpeg
Posts: 14
Joined: Mon Jan 23, 2023 6:34 pm
x 14

Re: BSID Bug?

Post by drmpeg »

How to use the utility. First get the base64 string with hdhomerun_config.

Image

Copy and paste the base64 string into a file with your favorite editor (for example, l1detail.txt). Then run the utility.

./l1dump l1detail.txt

Trip
Posts: 112
Joined: Sat Aug 07, 2010 6:49 am
Location: Alexandria, VA, USA
x 13
Contact:

Re: BSID Bug?

Post by Trip »

drmpeg wrote: Thu Aug 07, 2025 7:48 pm Here's the C code.
This is great! I have a question though. I see in your collection of tools that you have an atsc3rate.c which appears to calculate the total bitrate for a PLP. Is the data necessary to use this present in the l1dump output? I eyeballed it and couldn't immediately verify all the parameters are present, though I assume they are.

Also, would you mind if I integrated your code into my hdhomerun_tui utility I'm working on?

- Trip

drmpeg
Posts: 14
Joined: Mon Jan 23, 2023 6:34 pm
x 14

Re: BSID Bug?

Post by drmpeg »

Trip wrote: Fri Aug 08, 2025 6:51 pm
This is great! I have a question though. I see in your collection of tools that you have an atsc3rate.c which appears to calculate the total bitrate for a PLP. Is the data necessary to use this present in the l1dump output? I eyeballed it and couldn't immediately verify all the parameters are present, though I assume they are.

Also, would you mind if I integrated your code into my hdhomerun_tui utility I'm working on?

- Trip
Yes, all the parameters for atsc3rate.c are included in the l1dump output except for the L1 Basic FEC type/mode. That's because the L1 Basic FEC type/mode is signaled in the bootstrap.

The usage for atsc3rate.c is:

Code: Select all

usage: atsc3rate <fft size> <guard interval> <number of data symbols> <number of preamble symbols> <code rate> <modulation> <frame size> <pilot pattern> <first SBS> <L1 Basic mode> <L1 Detail mode> <reduced carriers> <pilot boost> <PAPR mode> <optional HTI blocks>

fft size = 8, 16, 32

guard interval = 1/192, 2/384, 3/512, 4/768, 5/1024, 6/1536, 7/2048, 8/2432, 9/3072, 10/3648, 11/4096, 12/3864

modulation 0/QPSK, 1/16QAM, 2/64QAM, 3/256QAM

frame size = 0/normal, 1/short

pilot pattern = 0/SP3_2, 1/SP3_4, 2/SP4_2, 3/SP4_4, 4/SP6_2, 5/SP6_4, 6/SP8_2, 7/SP8_4, 8/SP12_2, 9/SP12_4, 10/SP16_2, 11/SP16_4, 12/SP24_2, 13/SP24_4, 14/SP32_2, 15/SP32_4
The parameters are all numeric, which makes it a little difficult to use. It really needs to be a GUI app.

Also, not all modes are supported correctly. It's really only accurate for a single PLP configuration. For other modes like TDM, LDM and sub-frames, the number of L1_Detail cells needs to be a variable instead of hard coded like it is now. Also, the frame length time won't be correct for multiple sub-frames and/or time-aligned symbols. When I need to calculate the bitrate for those modes, I just make some edits to the code (instead of adding more parameters to an already long list).

Here's a single PLP example. l1dump first.

Code: Select all

L1B_version = 0
L1B_mimo_scattered_pilot_encoding = Walsh-Hadamard pilots or no MIMO subframes
L1B_lls_flag = No LLS in current frame
L1B_time_info_flag = Time information is not included in the current frame
L1B_return_channel_flag = 0
L1B_papr_reduction = No PAPR reduction used
L1B_frame_length_mode = symbol-aligned
L1B_time_offset = 256
L1B_additional samples = 0
L1B_num_subframes = 1
L1B_preamble_num_symbols = 1
L1B_L1_Detail_content_tag = 0
L1B_L1_Detail_size_bytes = 25
L1B_L1_Detail_fec_type = Mode 1
L1B_L1_additional_parity_mode = K=0 (No additional parity used)
L1B_L1_Detail_total_cells = 2787
L1B_first_sub_mimo = No MIMO
L1B_first_sub_miso = No MISO
L1B_first_sub_fft_size = 32K
L1B_first_sub_reduced_carriers = 5.832 MHz
L1B_first_sub_guard_interval = GI3_512
L1B_first_sub_num_ofdm_symbols = 49
L1B_first_sub_scattered_pilot_pattern = SP24_2
L1B_first_sub_scattered_pilot_boost = 1.718
L1B_first_sub_sbs_first = present
L1B_first_sub_sbs_last = present
L1B_crc = 0x00000000
L1D_version = 0
L1D_num_rf = No Channel Bonding
******** subframe = 0 ********
L1D_frequency_interleaver = All Symbols
L1D_sbs_null_cells = 1121
L1D_num_plp = 1
********** plp = 0 **********
L1D_plp0_id = 0
L1D_plp0_lls_flag = 1
L1D_plp0_layer = Core
L1D_plp0_start = 0
L1D_plp0_size = 1328400
L1D_plp0_scrambler_type = PRBS
L1D_plp0_fec_type = BCH + 64K LDPC
L1D_plp0_mod = 16QAM
L1D_plp0_cod = 7/15
L1D_plp0_TI_mode = Hybrid time interleaving
L1D_plp0_type = non-dispersed
L1D_plp0_HTI_inter_subframe = 0
L1D_plp0_HTI_num_ti_blocks = 3
L1D_plp0_HTI_num_fec_blocks_max = 82
L1D_plp0_HTI_num_fec_blocks = 82
L1D_plp0_HTI_cell_interleaver = enabled
L1D_crc = 0x03b4edcd
And atsc3rate.

Code: Select all

./atsc3rate 32 3 49 1 7 1 0 12 1 1 1 0 1 0 82
frame size = normal
code rate = 7/15
constellation = 16QAM
FFT size = 32768
number of data symbols = 49
number of preamble symbols = 1
guard interval samples = 512
pilot pattern = SP24_2
first SBS insertion enabled
L1 Basic mode = 1
L1 Detail mode = 1
bandwidth = 5.833 MHz
pilot boost = 1.718

clock rate = 6.912000 Msps, symbol time = 4.814815 ms
frame time = 242.740741 ms
total cells = 1340765
L1 cells = 6607
1st preamble cells = 24844
SBS null cells = 2242
PLP size = 1328400, unused cells = 3516, minimum TI blocks = 3
TS bitrate = 10145079.036
PLP bitrate = 10150483.979
The number of SBS null cells is the total. Since this configuration has both first and last SBS, it's 2X what's reported in l1dump. As it turns out, the number of SBS null cells is really a function of pilot boost even though it's signaled in the L1_detail. That's because the SBS has more pilots and the total power of the SBS symbol has to be adjusted (with null cells) to be the same as the other symbols.

BTW, I looked at your hdhomerun_tui code. There's a couple of bugs in the l1_detail code. The guard interval table starts at 1, not 0. Also, some parameter like number of symbols and TI blocks are signaled minus 1, so you have to account for that.

Trip
Posts: 112
Joined: Sat Aug 07, 2010 6:49 am
Location: Alexandria, VA, USA
x 13
Contact:

Re: BSID Bug?

Post by Trip »

drmpeg wrote: Fri Aug 08, 2025 9:15 pm BTW, I looked at your hdhomerun_tui code. There's a couple of bugs in the l1_detail code. The guard interval table starts at 1, not 0. Also, some parameter like number of symbols and TI blocks are signaled minus 1, so you have to account for that.
Thanks. Based on what you reported, I've opted not to try to incorporate it at this time. Perhaps down the road.

I'm not surprised it was riddled with errors. I tore it all out and adapted your code instead. I'm about to post a new version of it in a few minutes here.

- Trip

nickk
Silicondust
Posts: 20781
Joined: Tue Jan 13, 2004 9:39 am
x 395

Re: BSID Bug?

Post by nickk »

The encoding of L1detail is quite fussy.

ATSC 3.0 is an interesting mix of extreme binary like this and "lets base64 encode the data, put that in XML, then gzip the XML" :)

drmpeg
Posts: 14
Joined: Mon Jan 23, 2023 6:34 pm
x 14

Re: BSID Bug?

Post by drmpeg »

I've added the bit-rate calculator to l1dump. Except for the L1_Basic FEC mode issue, it should be accurate for all modes. Sub-frames were a bit of a pain. I had to parse the L1 data twice to make it work.

Also, there's now an l1dump.h file. https://github.com/drmpeg/dtv-utils

Post Reply