[mythtv] This piece of code is driving me nuts!

Roger James roger at beardandsandals.co.uk
Sat Nov 19 00:50:48 UTC 2016


On 18 November 2016 10:20:16 pm Karl Dietz <dekarl at spaetfruehstuecken.org> 
wrote:

> On 18.11.2016 18:53, roger wrote:
>> This piece of code in mpgestreamdata.cpp is driving me nuts.
>>
>> void init_sections(sections_t &sect, uint last_section)
>>
>> {
>>
>> static const unsigned char init_bits[8] =
>>
>> { 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, };
>>
>> sect.clear();
>>
>> uint endz = last_section >> 3;
>>
>> if (endz)
>>
>> sect.resize(endz, 0x00);
>>
>> sect.resize(32, 0xff);
>>
>> sect[endz] = init_bits[last_section & 0x7];
>>
>> }
>
> It creates a vector of 256bits packed into 32 unsigned chars of 8 bits.
> (256 being the maximum number of sections)
> Then initializes last_section bits to 0 and 256-last_section bits to 1.
>
> Later it looks at each received section and sets the corresponding
> bits. Once all bits are set we have collected the whole table.
>
> Regards,
> Karl

I had just about worked this out. The first resize is redundant and can be 
removed. The current code does not seem to use this for checking table 
completion. That is fine, as this would not work for segmented tables that 
can have gaps in the segment number sequence. So this function could be 
reduced to.

sect.resize(32, 0xff);

However it would be nice for table complete to be signalled in some way.

Roger






More information about the mythtv-dev mailing list