The trellis encoder is the part of the ATSC standard that adds the most excess data. It's also one of the last steps before transmission. It takes in 2 bits of data and outputs 3 bits. I opted to store the 3 bit symbols in 4 bits. At least initially, getting it to work correctly was more important that maximizing video play time.
If the trellis encoding could be done on the P2 the video playback time would be doubled. It would also make it easier to play longer videos directly from the SD card due to the reduced data rate required.
A Look-Up-Table can be a good way of computing complex operations quickly, provided the input space is not too large. In the graph we can see that the trellis encoder has 3 bits of memory inside. The table will need the current state as an input and the next state as an output.
| Input | Input | Output | Output | Total | % of | ||
| State | Data | State | Data | Table | table | On-chip | |
| bits | bits | bits | bits | entries | bits | bytes | RAM used |
| 3 | 2 | 3 | 3 | 32 | 6 | 24 | 0.00 |
| 3 | 4 | 3 | 6 | 128 | 9 | 144 | 0.03 |
| 3 | 8 | 3 | 12 | 2048 | 15 | 3840 | 0.73 |
| 3 | 16 | 3 | 24 | 524288 | 27 | 1769472 | 337.50 |
| 3 | 8 | 3 | 12 | 2048 | 64 | 16384 | 3.13 |
Processing 8 bits of data at a time results in a table of 2048 entries. Quite reasonable.
I opted to use 64 bits per entry to save time unpacking the results. The P2 has a burst memory access mode such that additional 32 bit words add only 1 clock cycle. Memory usage of 16kB of the 512kB is quite tolerable.
The trellis encoder along with associated housekeeping uses about 50% of one core of the P2 microcontroller at 300MHz.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.