mipops / dvrescue

Archivist-made software that supports data migration from DV tapes into digital files suitable for long-term preservation. Snapshot daily builds are at https://mediaarea.net/download/snapshots/binary/dvrescue/.
BSD 3-Clause "New" or "Revised" License
94 stars 20 forks source link

support absolute track number #216

Closed dericed closed 3 years ago

dericed commented 3 years ago

add the following attributes:

@abst is parsed as described on page 181 of iec61834-1{ed1.0}b.pdf. It is a 23 bit value written in the ssyb packs of the subcode section. Currently mediainfolib (as does smpte 314m) refers to abtn as arbitrary bits:

<block offset="99" name="ssyb" size="8">
  <data offset="99" name="FR - Identification of half of channel">Yes</data>
  <data offset="99" name="Res - Reserved" info="(3 bits)">7</data>
  <data offset="100" name="Arb - Arbitrary bits" info="(8 bits)">0</data>
  <data offset="100" name="Syb - SSYSB number" info="(4 bits)">2</data>
  <data offset="101" name="0xFF">255</data>
  <block offset="102" name="FF" size="5">
    <data offset="102" name="Pack Type">255</data>
    <data offset="103" name="Unused">4294967295</data>
  </block>
</block>

The 8 bit arbitrary bits of each triplet of sync blocks compose the 24 bits of the 23-bit abst value and the blank flag (bf). For quick reference the 24 bit value can be extracted (from a healthy frame) with xxd -ps -c 80 single-frame.dv | grep ^3.0.00 | awk '{print substr($0,40,2) substr($0,24,2) substr($0,8,2)}'. As with timecode, if the pack containing the value is all-null or all-ones then check for another occurrence. Each subcode dif block should contain two copies of the abst, so 40 copies all together.

Each dif sequence of the frame will have its own abst value. I propose in the xml that the abst is the value of the first dif sequence. If the first dif sequence does not have a valid abst, then read from the first valid dif sequence abst. If the first value abst is in dif sequence n then store abst as a value of n:abst - (dif_sequence_number * abst_increment) to infer what the first abst value would have been if read correctly.

As usual @abst_r would flag repeated values of abst and @abst_nc would note when the abst does not follow the incrementation pattern. Invalid abst should be excused from triggering _r or _nc.

@bf would be the last bit of the 24 bit sequence. Default as zero and unstored, but include @bf=1 if present. The @abstvalue should be stored in the xml as a decimal, converting the 23 bit value to decimal format.

Notes on validating the 8-bit values of the abst. The four bits following each 8 bit value are the Subcode sync block number values which number the 12 subcode blocks from 0x0000 - 0x0011. So the Subcode sync block number could be verified to make sure they match their position in the subcode and if not then ignore the 8 bit component of the abst.

For example, here's the hex of the first 12 subcode blocks of a frame. The 2nd column (8 bit) shows the 24 bits of the abst+bf and the 3rd column (4 bit) shows the subcode sync block number. The subcode sync block number show a cycle of 0-b and thus all blocks validate the test and the 1st abst+bf is 001c22 and the second abst+bf is 001c3e.

8 22 0 ff ffffffffff 
f 1c 1 ff ffffffffff
f 00 2 ff ffffffffff
f 22 3 ff 1340000000
f 1c 4 ff 1401201511
f 00 5 ff 1340000000
0 3e 6 ff ffffffffff
7 1c 7 ff ffffffffff
7 00 8 ff ffffffffff
7 3e 9 ff 1340000000
7 1c a ff 62ffd0e702
0 00 b ff 63e4d496e2
JeromeMartinez commented 3 years ago

frame/@abst has 10 (consecutive) 2 2 values per frame, I suggest to provide the smallest one in the XML output, fine enough? Then we could add info when values are not the expected ones in the same frame (not same/consecutive etc)

dericed commented 3 years ago

well officially $DIF_SEQUENCE_PER_FRAME_COUNT 2 2. Smallest is okay, if you dismiss values that are stored within nulled packs (example: the nulled subcode blocks in https://mediaarea.net/DVAnalyzer/dif-incoherency shouldn't result is @abst=0 if other subcodes contain valid abst.)

I am still uncertain if the incrementation of abst is consistent from dif sequence to dif sequence, but if consistent then you could use @abst - $number_of_dif_sequence_the_abst_was_found_in * $some_increment_multiplier to approximate what the first abst of the frame should be.

JeromeMartinez commented 3 years ago

@bf would be the last bit of the 24 bit sequence. Default as zero and unstored, but include @bf=1 if present.

@bf is at 99.999% always 1 ( = no discontinuity). I suggest default 1 and displayed if present and 0. We could also inverse the logic (1 mean discontinuity) but may be misleading for people reading the spec.

dericed commented 3 years ago

Resolved in https://github.com/mipops/dvrescue/pull/242, excepting @bf for later investigation.