Skip to content

GNRC Tutorial Wiki Part 5: Make a simple GNRC graph to play a .tbc file

tandersn edited this page Nov 27, 2022 · 4 revisions

Hands On: Creating your own graph.

For an exercise (requires you have a .tbc file on your machine), let's create our own graph to play a .tbc file in the Video SDL sink. Simply follow the following steps in GNRC:

  • Select File --> New QT GUI
  • Double click the samp_rate variable block and enter 14318181 value field (this is NTSC, for PAL see the sample rate page).

Input Stage

  • As we found out earlier, a .tbc file is u16 data type, and GNRC does not natively support this data type. So we are going create a set of input blocks to get where we need to go (converting 2 bytes to their u16 value inside a float data type). For our input stage, add the following blocks using the "search" and "double click" in the right tree list (see blocks page):
    • File Source
    • Uchar To Float
    • Deinterleave
    • Multiply Const
    • Add
  • Double click the File Source block and set the following:
    • Use the file search button to select a .tbc file on your filesystem (see cvbs/ld/vhs decode on how to make one)
    • Output Type = "byte"
    • Repeat = "no"
  • Select the Deinterleave and press the "Down Arrow" key once to switch it to "float" data type.
  • Double click the Multiply constant block and set the following:
    • Value = 256
    • IO Type = float
  • Select the add block and press the "Down Aarrow" key once to switch it to "float" data type.
  • Connect all the blocks as you see in this image:

Set up processing for Video SDL Link (need to convert 0-65535 values to 0-255 range and "throttle" the rate we process)

  • Search, Find, Add, a Throttle block and connect the input of the throttle to the output of the add. Use the "down arrow" to set it to "float".
  • Search, Find, Add, a Divide block. Use the "down arrow" to set it to "float". Connect the "out" of throttle to the "in0" of divide.
  • Search, Find, Add, a Constant Source block, double click and set value to 256 and type to float. Connect the "out" of Constant Source to the "in1" of divide.
  • Search, Find, Add, a rail block, set the "low" value to 0, and the "high" value to 255.
  • Search, Find, Add, a Float To Uchar block, connect the "in" of Float To Uchar to the "out" of the Divide.
  • Search, Find, Add, a Video SDL Sink block. connect the "out" of Float To Uchar to the "in" of the Video SDL Sink.
  • Double click the Video SDL Sink and set the "input width" to 910 NSTC or 1135 PAL. Set the "input hieght" to 526 NTSC or 626 PAL.

When your graph is done, and you play it, it should look something like this:

Here's a block by block explanation of what is happening:

NOTE: The only thing we are really doing here, is converting data types. If GNRC suppored u16 data type, and if Video SDL Sink supported u16 data type, you could simply have a File Source connected directly to a Video SDL Sink (with possibly a Throttle in between.

Also NOTE: It is normal for the fields to be shown this way, that's how they are stored in the file, and how they were transmitted OTA back in the days of analog television.


A copy of the graph created here can be found in the tutorial github repo: Here