HASH2›› Time/length hash› ----------------››Given a set of times (let us limit›them to half hours during the day,›with 24*2 possibilities) and›durations (let us limit them to up to›five hours but only times which are›even multiples of half hours, for 2*5›possibilities), there are›24*2*2*5=480 possible values for time›and length.››Now one COULD try to find out how›these are hashed (to create another›number of up to nine bits), but it is›easier to simply find the values›corresponding to each time duration›and use table look up.››In fact, if HR is the hour (0-23) and›MIN is the minute (for the start of›the show) and DUR is the duration in›minutes (30-300), let›TDUR=10*(2*HR+MIN/30)+(DUR-30)/30.››The smallest value is for HR=0=MIN,›DUR=30 (giving TDUR=0) and the›largest is for HR=23, MIN=30, DUR=300›or 479.››This is a simple pack-encoding of›TIME and LENGTH into a TDUR value,›but it IS not the value used by the›VCR+... instead the VCR+ hashes this›value to another number from 0 to›479.››The easiest way to do this is to let›TL be the value that VCR+ uses and›find out what it is by experiment and›set up arrays:››AR1(TDUR)=TL and AR2(TL)=TDUR››(AR1 enables one to hash the value of›TIME/DURATION to the TL value needed›by VCR+ for encoding, while AR2›enables one to dehash the VCR+ value›needed to the actual time/duration).››These values are contained in the›arrays in the C-source code that is›around for VCR+ encoding (but only›AR2 is given, and the TIME and›DURATION are not packed into one TDUR›number, but are given as two›arrays... also, the C-source code›simply searches the AR2 arrays to›find the TL value that corresponds to›the correct TIME/DURATION... it is›much faster for encoding to set up›the inverse array AR1 for encoding!››Thus, TL is the hashed value of TDUR›(time and duration... TDUR is just a›packed value corresponding to›starting time and duration) and as›this is such a short table, there is›no need to work out the logic behind›the hashing, but we simply use a look›up table to hash, dehash.››NOTE that this only hashes/unhashes›starting times beginning on an hour›or half hour and for lengths that are›an integral number of half hours!››NOTE that the TL (hashed value) (as›well as TDUR) is nine-bits long.››We will assume a TL value (nine-bits)›and a channel number of six-bits›(channels 0-63... actually if CH is›the channel number, we take CV the›channel value as CH-1, so we can have›CH from 1-64 and handle 64›channels)... does the VCR+ handle›more channels/times?››I don't know... but the C-source code›gives the hash for changing the TL/CV›values to two other numbers (of›ten/five-bits) A,B as follows:››(in the following, the numbers are›written in BINARY with the relevant›bits listed from most significant to›least)››If TL= t8,t7,t6,t5,t4,t3,t2,t1,t0›› CV= c5,c4,c3,c2,c1,c0››Then›› A=t8,c5,t7,c4,t6,t5,t4,c3,c2,t3›› B= t2,c1,t1,c0,t0››To decode, if we have:›› A=a9,a8,a7,a6,a5,a4,a3,a2,a1,a0›› B= b4,b3,b2,b1,b0››Then:›› TL= a9,a7,a5,a4,a3,a0,b4,b2,b0›› CV= a8,a6,a2,a1,b3,b1›› -----››Given a TIME and DURATION one gets a›TDUR value and hashes (lookup table)›to TL... given a CHannel, we take›CV=CH-1 and hash with TL to get a ten›bit and five bit numbers, A/B.››To dehash, we convert from our›ten/five bit numbers A/B to TL and CV›(nine/six bits) giving the channel›number, and use the lookup table to›recover the time/duration (TDUR)›from TL.››NOTE that this hash/dehash algorithm›is only valid for 1<=channel<=64 and›time/durations of even half hours.›