f4exb / sdrangel

SDR Rx/Tx software for Airspy, Airspy HF+, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay and FunCube
GNU General Public License v3.0
2.94k stars 447 forks source link

AM Analog TV rendering issues (horizontal line shift) #459

Closed Vort closed 4 years ago

Vort commented 4 years ago

I have recently found a sample of TV signal: Принимаем и декодируем аналоговое ТВ с помощью SDR и Python. And converted it to .sdriq format.

I have tried to decode it with both 4.12.3 and 4.11.6, but had no luck with getting a stable result. It may be that I am setting wrong parameters to ATV Demodulator, but, most likely, it is just glitchy. Fixing of this problem would be a good task for someone who want to improve SDRangel. Here is the file, which can be loaded with FileInput plugin: atv_sample.sdriq (941 MiB).

And here is the screenshot of current decoding with 4.12.3: atv

Related: #21

Vort commented 4 years ago

If you would like to squash some commits before you are welcome to do so.

Here is the result: https://github.com/Vort/sdrangel/commit/4afd5a7a2d9fd7cd14f1573b5ff4ff4876d14fda. It should differ from https://github.com/Vort/sdrangel/commit/ff8368470744d78b573c6977f6e94153a96b5504 only by whitespace changes.

f4exb commented 4 years ago

OK great! you or I can make a PR.

Vort commented 4 years ago

Is there a reason for it? Commit can be applied without PR. Even merge commit is not needed in this case. I am not against creation of PR, just trying to understand situation.

f4exb commented 4 years ago

Changes are in your fork so unknown to the f4exb repository. I don't know how this can work without a PR. I can make a diff on my clone and patch but your signature will disappear. It is as you like.

Vort commented 4 years ago

It is done by linking to my repository (adding remote or something). If you find how to do it, then PR will be closed automatically. If not (or do not want to do this), then just merge it: #576.

f4exb commented 4 years ago

Yes it seems to be working. In the same manner a diff can be done across remotes a merge can be done also and keeps the signature of the commit.

Vort commented 4 years ago

Can you adjust timings in modulator and fix incorrect interleaving there? (I can make separate report for it if needed)

f4exb commented 4 years ago

What do you mean by "incorrect interleaving" ?

Vort commented 4 years ago

Use this file for transmission in 625 mode:

White line ![576pixels_line](https://user-images.githubusercontent.com/1242858/87903563-f4c03900-ca64-11ea-98f6-3820bc207c12.png)

Edges of the white line should be smooth.

But instead you can see swapped scanlines: ![line_test](https://user-images.githubusercontent.com/1242858/87903675-3ea91f00-ca65-11ea-8d37-a34c7807a246.png)

This was not visible before because equivalent bug existed in demodulator.

f4exb commented 4 years ago

You mean interleaving or interlacing? The code has a m_interleaving indicator but I think this should be m_interlacing if this is interlacing then I think it is correct. The roughness observed on the edge is not due to wrong interlacing order for two reasons:

The effect on the chessboard pattern is even more dramatic

Correct interlacing ![2020-07-21-231036_924x874_scrot](https://user-images.githubusercontent.com/6192319/88108947-f9423a00-cba9-11ea-909b-f18bca3309f3.png)
Wrong interlacing ![2020-07-21-230907_1001x801_scrot](https://user-images.githubusercontent.com/6192319/88108847-d152d680-cba9-11ea-978b-e5bf059a0396.png)

I had the issue some time ago and I had to correct it.

Note: this is the declaration of m_interleaving:

bool     m_interleaved;      //!< true if image is interlaced (2 half frames per frame)

"interlaced" is the right term I think.

Vort commented 4 years ago

"interlaced" is the right term I think

Yes, I was using the term, which is used in code.

if this is interlacing then I think it is correct.

My test was not good at displaying the problem. Here is the new one:

Source: ![576pixels_test2](https://user-images.githubusercontent.com/1242858/88138670-cd00da80-cbf6-11ea-971a-d8e61639b623.png)
Here is wrong encoding: ![tv_test_bad](https://user-images.githubusercontent.com/1242858/88138680-d1c58e80-cbf6-11ea-899a-0b15e468cedd.png)
Here is good encoding: ![tv_test_good](https://user-images.githubusercontent.com/1242858/88138692-d5f1ac00-cbf6-11ea-8ba9-5dfebc62f65d.png)
Zoomed: ![tv_bad_zoom](https://user-images.githubusercontent.com/1242858/88138852-2cf78100-cbf7-11ea-8bee-b744c1a41720.png)
f4exb commented 4 years ago

OK but I think this is not an even/odd field swapped issue. The ShortI works fine and all PALxxx are affected. ShortI uses the least possible frames for vertical sync so the issue is probably in an incorrect number of frames in the vertical sync sequence or a half line mismatch.

Edit: I used your picture as an image source to test but I think this zigzag pattern is an interesting pattern to add to the list of generated patterns.

Vort commented 4 years ago

I was fixing line count in demodulator too. According to standard (do not remember which one, but can google it), digitized 625-lines mode should contain 576 visible lines. Maybe if you fix it, incorrect line order will go away. _ Actually, first half of the top line and second half of the last line should be black. And it is not precisely "half", but that is details._

f4exb commented 4 years ago

The above issue is open to specifically address the ATV Modulator issues (it now deserves its own).