Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 13th October 2022, 21:58   #1  |  Link
RGMOfficial
Registered User
 
RGMOfficial's Avatar
 
Join Date: May 2022
Location: Brazil
Posts: 27
Trying to recreate a composite signal simulation

I've been thinking very much about doing an simulation of an video signal through Composite.

But i will need some help in order to get that done.
If this idea works well, i will try to rewrite DotCrawl++ to use this new script.

First is to create a luma signal.
The luma signal has an checkerboard look (and that's where dotcrawls come from).

I will be very thankfully for the help.

Images from DoctorDothraki's Domesday Duplicator uploads.


__________________
AviSynth+ Projects:
DotCrawl++
RGMOfficial is offline   Reply With Quote
Old 13th October 2022, 23:07   #2  |  Link
DTL
Registered User
 
Join Date: Jul 2018
Posts: 900
Luma do not have dotcrawl - it is chroma encoded addition. So to create more or less standard chroma subcarrier data it is required to read documentation and implement colour encoder to target colour system (typically PAL or NTSC) and more or less simply mix to luma data. The full composite encoder may (or typically do) have luma partial suppression filter at chroma band to make cross-distortions less visible. So better composite simulation mixer need also filter luma signal before final output mix.

Signal with checkerboard it is already mixed composite signal (luma +encoded chroma). The PAL/NTSC chroma subcarrier have phase flip to 180degrees (inversion) at each line to make residual distortion (after not ideal luma/chroma separation at decoder) less visible (checkerboard instead of vertical lines).

The sad story about digital processing after composite decoder - the input composite signal may be partially damaged after passing colour decoder (its residual colour subcarrier that cause effect of dotcrawl) so it may be not completely equal to simulated standard composite data. It may have both phase and amplitude errors not present in input composite data and these errors may be unique for each colour decoder implementation. So better way is in that doomsday-duplicator project is full composite colour decoder with dotcrawl effect suppression by single developer - not trying to make addition to (unknown) external decoder.

Last edited by DTL; 13th October 2022 at 23:16.
DTL is online now   Reply With Quote
Old 13th October 2022, 23:10   #3  |  Link
RGMOfficial
Registered User
 
RGMOfficial's Avatar
 
Join Date: May 2022
Location: Brazil
Posts: 27
Quote:
Originally Posted by DTL View Post
Luma do not have dotcrawl - it is chroma encoded addition. So to create more or less standard chroma subcarrier data it is required to read documentation and implement colour encoder to target colour system (typically PAL or NTSC) and simply mix to luma data.

Signal with checkerboard it is already mixed composite signal (luma +encoded chroma). The PAL/NTSC chroma subcarrier have phase flip to 180degrees (inversion) at each line to make residual distortion (after not ideal luma/chroma separation at decoder) less visible (checkerboard instead of vertical lines).
Oh. Understand.
Interesting info though.

Let's see. How i can make this chroma addition?
I need to think about it.
__________________
AviSynth+ Projects:
DotCrawl++
RGMOfficial is offline   Reply With Quote
Old 13th October 2022, 23:31   #4  |  Link
DTL
Registered User
 
Join Date: Jul 2018
Posts: 900
Take any open documentation on your target colour composite system encoder and make math program to some execution environment.

PAL and NTSC quadrature modulation is simple enough like multiplication and sum of sin() functions. I think most information can be taken from ITU-BT 470 - https://www.itu.int/dms_pubrec/itu-r...1-S!!PDF-E.pdf

For example math equation for chroma signal from 2.9 of Table 2. Also read about phase switching of chroma subcarrier - like 2.16 of Table 2 and may be other notes in that document.
DTL is online now   Reply With Quote
Old 13th October 2022, 23:45   #5  |  Link
RGMOfficial
Registered User
 
RGMOfficial's Avatar
 
Join Date: May 2022
Location: Brazil
Posts: 27
Quote:
Originally Posted by DTL View Post
Take any open documentation on your target colour composite system encoder and make math program to some execution environment.

PAL and NTSC quadrature modulation is simple enough like multiplication and sum of sin() functions. I think most information can be taken from ITU-BT 470 - https://www.itu.int/dms_pubrec/itu-r...1-S!!PDF-E.pdf

For example math equation for chroma signal from 2.9 of Table 2. Also read about phase switching of chroma subcarrier - like 2.16 of Table 2 and may be other notes in that document.
Very interesting and helpful.
I will see if i can use math with images on AVS, and then use these equations.
__________________
AviSynth+ Projects:
DotCrawl++
RGMOfficial is offline   Reply With Quote
Old 14th October 2022, 00:17   #6  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 1,813
If had new ver, can you notification at your doom9 post??
kedautinh12 is offline   Reply With Quote
Old 23rd October 2022, 18:11   #7  |  Link
RGMOfficial
Registered User
 
RGMOfficial's Avatar
 
Join Date: May 2022
Location: Brazil
Posts: 27
I'm trying out some way...

Code:
Tweak(hue=44)

Y = ShowY()
I = ShowU()
Q = ShowV()

C = BlankClip(last).mt_lutspa(mode="absolute", chroma="-128", expr=("x 4 % 2 < 0 1 ? y 4 % 2 < 0 1 ? + 1 == 0 255 ?"))

I_luma = ex_lutxy(I,C,"x y - abs")
Q_luma = ex_lutxy(Q,I_luma,"x y - abs")

Y = ex_lutxy(Y,Q_luma,"x y + abs")

return Y
__________________
AviSynth+ Projects:
DotCrawl++

Last edited by RGMOfficial; 23rd October 2022 at 18:12. Reason: Forgot to clear the code a bit
RGMOfficial is offline   Reply With Quote
Old 23rd October 2022, 21:30   #8  |  Link
RGMOfficial
Registered User
 
RGMOfficial's Avatar
 
Join Date: May 2022
Location: Brazil
Posts: 27
So what about the chroma signal?
__________________
AviSynth+ Projects:
DotCrawl++
RGMOfficial is offline   Reply With Quote
Old 24th October 2022, 15:48   #9  |  Link
RGMOfficial
Registered User
 
RGMOfficial's Avatar
 
Join Date: May 2022
Location: Brazil
Posts: 27
Now, if someone can help fix the chroma issue i had.

(I'm using an DotCrawl++ function for the mults at the moment, but i will change to an original function later)

Code:
function composite_effect(clip clip, float "subcarrier_amplitude"){
    subcarrier_amplitude = Default(subcarrier_amplitude,0.5)
    
    clip.Tweak(hue=44)

    Y = ShowY()
    I = ShowU()
    Q = ShowV()

    ## LUMA SIGNAL (merge information from chroma planes)

    U_C = dcpp_makedotcrawl(2)
    V_C = ex_invert(U_C)

    I_luma = ex_lutxy(I,U_C,"x y - abs "+string(subcarrier_amplitude)+" *")
    Q_luma = ex_lutxy(Q,V_C,"x y - abs "+string(subcarrier_amplitude)+" *")
    
    Y = ex_lutxyz(Y,I_luma,Q_luma,"x y + z + abs "+string(subcarrier_amplitude)+" *")
    
    I = BlankClip(Y)
    Q = BlankClip(Y)

    c = Overlay(BlankClip(Y),Y,x=2)

    sum = ex_lutxy(Y,c,"x y -")

    sum = sum.Overlay(c,mode="add",mask=c,opacity=1).blur(1,0)

    Y = sum.Levels(0,1,128,0,255)
    chroma = ex_lutxy(c,Y,"x y 0.5 * -")

    chroma = invert(chroma)

    chroma = ex_lut(chroma,"x 0.31 * 0.5 /").invert()

    chroma_s1 = Overlay(BlankClip(chroma),chroma,x=2)

    chroma_s3 = Overlay(chroma,chroma,x=2,mask=U_C)
    chroma_s4 = Overlay(chroma,chroma,x=2,mask=V_C)

    I_1 = Overlay(chroma_s3,chroma_s3,x=2,mask=U_C)
    Q_1 = Overlay(chroma_s4,chroma_s4,x=-2,mask=V_C)

    I_2 = Overlay(chroma_s4,chroma_s4,x=-2,mask=U_C)
    Q_2 = Overlay(chroma_s3,chroma_s3,x=2,mask=V_C)

    GScriptClip(last,"""
    #Y = ConditionalSelect(Y, "current_frame % 2",Y,Y_test)
    I = ConditionalSelect(I, "current_frame % 2",I_1,I_2)
    Q = ConditionalSelect(Q, "current_frame % 2",Q_1,Q_2)
    """,local=true)

    I = I_1
    Q = Q_1

    return YToUV(I,Q,Y).Tweak(hue=-44)
    StackHorizontal(last,vid)

    #StackHorizontal(original,chroma)
}
__________________
AviSynth+ Projects:
DotCrawl++
RGMOfficial is offline   Reply With Quote
Old 24th October 2022, 20:45   #10  |  Link
DTL
Registered User
 
Join Date: Jul 2018
Posts: 900
After you calculate I and Q chroma signals - you need to quadrature modulate chroma subcarrier and mix (addition) it with your luma data. The composite data is Y-only - not visibly colored. To demodulate it back to coloured you need to process it with composite decoder. I not sure if it is easy to do with AVS scripting only - better with C-program.

Last edited by DTL; 25th October 2022 at 08:01.
DTL is online now   Reply With Quote
Old 25th October 2022, 00:33   #11  |  Link
RGMOfficial
Registered User
 
RGMOfficial's Avatar
 
Join Date: May 2022
Location: Brazil
Posts: 27
Quote:
Originally Posted by DTL View Post
After you calculate I and Q chroma signals - you need to quadrature modulate chroma subcarrier and mix (addition) it with your luma data. The composite data is Y-only - not visibly colored. To demodulate it back to coloured youneed to process it with composite decoder. I not sure if it is easy to do with AVS scriptong only - better with C-program.
Ok, so can you show me in C program? Maybe i can translate this code into AviSynth.
__________________
AviSynth+ Projects:
DotCrawl++
RGMOfficial is offline   Reply With Quote
Old 25th October 2022, 08:02   #12  |  Link
DTL
Registered User
 
Join Date: Jul 2018
Posts: 900
For software composite demodulator you may look at vhs-decode project https://github.com/oyvindln/vhs-decode . Looks like this file https://github.com/oyvindln/vhs-deco...ode/process.py
DTL is online now   Reply With Quote
Reply

Tags
composite, ntsc, simulation

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:23.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.