Want to resurrect your D/D2 MAC kit?

Love this bit of code :D

Code:
/* Simulated line cut-and-rotate video scrambling */
    if(seq[2] == 'a' && seq[3] == 'a')
    {
        int c1 = rand() % s->active_width;
        int c2 = s->active_width - c1 - 1;
      
        for(x = s->active_left; x < s->active_left + c2; x++)
        {
            s->output[x * 2 + 1] = s->output[(x + c1) * 2];
        }
      
        for(; x < s->active_left + s->active_width; x++)
        {
            s->output[x * 2 + 1] = s->output[(x - c2) * 2];
        }
      
        for(x = s->active_left; x < s->active_left + s->active_width; x++)
        {
            s->output[x * 2] = s->output[x * 2 + 1];
        }
    }

Real-time Videocrypt encoder ;) Cut-point range on the 'real' encoder is I think between 20 and 236, instead of 1 to 255 (or 1 to active_width) but that's a moot point at this stage. Nice work!

 
I couldn't resist :) It certainly looks the part. It's impressive how much a simple line operation can obscure the image.

I've pushed a fix for that repeat bug. Also added the old 405-line TV mode, if anyone still has one of those about.
 
Thanks Phil :) Will check it.

I've been messing about a little and added a few more lines of code to give me a little Videocrypt and Nagravision demo in 4 second (or 100 frame) intervals. What's truly impressive is that this is completely real time and doesn't strain my VM at all.

For "Nagravision", it was literally one line of code to mix up the line orders.

Code:
        /* Calculate the active line number */
         vy = (s->line < 313 ? (s->line - 23) * 2 : (s->line - 336) * 2 + 1);
+        if (s->frame%400 > 100 && s->frame%400 < 200) vy = (vy > 0 ? rand() % 200 + vy  : vy);
         if(vy < 0 || vy >= s->conf.active_lines) vy = -1;

The effect is pretty cool, though Nagra part looks more RGB or SECAM like, rather than PAL... but hey :)

I am going to add a couple of switches to demo toggle these erm... "features". I can do a pull request if you like but no doubt you can do a much better job!

 
That looks familiar! Yeah the colour shouldn't be preserved, to make it more authentic it would need the lut_u and lut_i values scrambled along with the active line.
 
PAL or MAC audio? :)

Nothing to report for either yet. Plans to work on it over the holiday weekend quickly evaporated.
I did dig out my old flow graph for adding PAL-I audio and updated it for taking input from hacktv: System I audio hack · GitHub

Needs a separate wav file, which it assumes is mono at 32khz sample rate. I've set the deviation to 200khz which is four times what it should be, as the sample I was testing with was too quiet.
 
I should add that this script is *just* slightly too slow to run on my PC in real time. It starts glitching after about 10 seconds.
 
Thanks Phil. Will check it out. I am following you on github, so looking in there now and again.

In the meantime, I've been playing some more with video sources. One of the main things I've noticed is that various videos appeared stretched depending on the source. Obviously, ffmpeg was simply taking the input and passing it to the frame handler/resizer unchanged, so I needed to run the video past some filter to resize/pad the edges depending on source's aspect ratio.

This took me pretty much most of the Bank holiday weekend to work out - libavfilter's docs are not simple for the novice! Eventually I managed to pass the decoded frames through a filter graph to add padding and scaling and pass it back to frame handler.

While I was there, I thought I'd add some overlays in form of logos. My absolute favourite one is that of TV1000 from 1994/1995 - it's a simple and small black and white logo, which sat neatly in top left corner (not great for screen burn-ins though!). Various incarnations after that - and they seem to change every year - are a bit rubbish and uninspiring. A logo can be any png file (or any format that libavfilter/codec will accept - even a movie file!) - some channel logos are available online in vector format, so can be resized and coloured very easily.

(The code for everything is *extremely* ugly! Logos' filenames are hardcoded and have to recompile every time I change it - so need to add it as switch parameters. Happy to send it to you if you think any of it is useful.)

Here's the result - see if you can spot the logos :):-

 
Last edited:
That's pretty cool!

Yes ffmpeg's API is not great. I'm new to it myself. I did manage to get it to decode audio but have since broken it again...

hacktv just resizes the source video to the full TV frame regardless of resolution or ratio. That bit could definitely be made a bit smarter.
Would also be nice to add the WSS code to signal to the TV if something is 16:9.
 
Ah, yeah, forgot about WS signals - I wouldn't know where to start there! The PAL encoding is an enigma for me. I understand MAC better than I do PAL - it seems like a simpler mechanism as it's all linear.

Yeah, at moment I am just resizing it to fit my no-name TV's screen with a 'close-enough' aspect. The filter graph for 4/3 and WS is this:

Code:
    aw = s->vid.width;
    ah = s->vid.conf.lines;
    sw = av->codec_ctx->width;
    sh = av->codec_ctx->height;

    if((sw/sh) > (aw/ah)) /* check if source video's ratio is bigger than TV screen's (16/10-ish for me, which coincidentally is full frame's ratio (1024/625)) */
    {
        /* widescreen padding - letterbox */
        sprintf(fi,"[in]pad=""iw:iw/(%f/%f):0:(oh-ih)/2"",scale=%f:%f[video]; \
                movie=tv1000.png,scale=iw/(1024/%f):iw/(iw/ih)/(576/%f)[tvlogo]; \
                movie=satsuk.png,scale=iw/(1024/%f):iw/(iw/ih)/(576/%f)[satslogo]; \
                [video][tvlogo]overlay=%i:%i[logos]; \
                [logos][satslogo]overlay=%i:%i[out]",
                aw,ah,sw,sh,
                sw,sh,
                sw,sh,
                (int) (sw*12/15),(int) (sh*1/10),
                (int) (sw*12/16),(int) (sh*10/12)
                );
    }
    else
    {
        /* 4/3 padding - pillarbox */
        sprintf(fi,"[in]pad=""iw*(4/3):ih:(ow-iw)/2:0"",scale=%f:%f[video]; \
                movie=tv1000.png,scale=iw/(1024/%f):iw/(iw/ih)/(576/%f)[tvlogo]; \
                movie=satsuk.png,scale=iw/(1024/%f):iw/(iw/ih)/(576/%f)[satslogo]; \
                [video][tvlogo]overlay=%i:%i[logos]; \
                [logos][satslogo]overlay=%i:%i[out]",
                sw,sh,
                sw,sh,
                sw,sh,
                (int) (sw*12/15),(int) (sh*1/10),
                (int) (sw*12/16),(int) (sh*10/12)
                );
    }

As you can see - pretty ugly and definitely needs tidying up.
 
Hi Phil, just wondering if you made a start on C version of MAC encoder? Looking at the Python code, it should relatively easy to convert from that to C and hopefully get enough performance benefits to do the encoding real time? The only other thing that would need to happen to changing the modulation so it can be accepted by a satellite receiver.
 
Hi all,

If anyone is interested, Phil has pushed audio support to Github for his PAL encoder. Works pretty well, though there are some minor sync issues.

GitHub - fsphil/hacktv: Analogue TV transmitter for the HackRF

In the meantime, I received my Pace MDR960 receiver today - works pretty well with existing MAC encoder, though glitches with either HackRF or my VM or USB send it spinning still.

 
Progress update, the BSB receiver is now happy with the signal! Reporting a good signal, and now lets me view the channel in non-setup mode.

The data burst now contains valid but empty packets. The receiver must have been using these packets to measure signal strength, and the random data I was filling it with was making it unhappy. Next step, filling the data burst with useful data (audio).
 

Attachments

  • IMG_20170616_224441656.webp
    IMG_20170616_224441656.webp
    129.5 KB · Views: 44
Have been playing with my new VCR and took a capture of some FilmNet 1 trailers.


This one has the notification of FilmNet move from Astra 1 to Thor 1 at 3:30. This was my worst nightmare, since I could not receive Thor 1 at all on an 80cm dish. Thankfully, Thor 2 was launched a few months later and they moved it to that, which was nice and strong. Of course, within a week FilmNet became Canal+, which was still a good channel (4 of them even!) but nothing will beat FilmNet.

And I found this in an old Wotsat mag....

2017-06-21 12.06.34.webp
 
Last edited:
Have been playing with my new VCR and took a capture of some FilmNet 1 trailers.


This one has the notification of FilmNet move from Astra 1 to Thor 1 at 3:30. This was my worst nightmare, since I could not receive Thor 1 at all on an 80cm dish. Thankfully, Thor 2 was launched a few months later and they moved it to that, which was nice and strong. Of course, within a week FilmNet became Canal+, which was still a good channel (4 of them even!) but nothing will beat FilmNet.

And I found this in an old Wotsat mag....

View attachment 108074
I met Ken Cook who ran Transworld, great guy!
 
"MAC to life". Now why didn't I think of that.
 
Been working on a VirtualDub plugin to recreate MAC video along with Eurocrypt type encryption. All simulation, of course, you can't send it to the real MAC decoder and expect it to work. The VD plugin can convert either way.

Plain RGB to MAC:

Screenshot 2018-04-16 10.31.49.webp

RGB to MAC + Eurocrypt with seed:

Screenshot 2018-04-16 10.32.20.webp

Reverse of the above:

Screenshot 2018-04-16 10.33.59.webp

From Encrypted MAC to RGB without decryption:

Screenshot 2018-04-16 10.34.30.webp

From Encrypted MAC to RGB with wrong seed (which is what you saw in reality without a valid card):

Screenshot 2018-04-16 10.34.56.webp

Small demo...

 
Back
Top