> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Support software TNR/MCTF

> Implement GPU-based Motion Compensated Temporal Filter (MCTF) to enhance preview and video quality by reducing noise and refining motion clarity on IQ-9075-EVK and IQ-8275-EVK.

<div style={{display:'flex',gap:'8px',flexWrap:'wrap',marginBottom:'16px'}}>
  <span style={{background:'#ede9fe',color:'#5b21b6',padding:'2px 10px',borderRadius:'999px',fontSize:'12px',fontWeight:600}}>IQ-9075-EVK</span>
  <span style={{background:'#ede9fe',color:'#5b21b6',padding:'2px 10px',borderRadius:'999px',fontSize:'12px',fontWeight:600}}>IQ-8275-EVK</span>
  <span style={{background:'#f0fdf4',color:'#166534',padding:'2px 10px',borderRadius:'999px',fontSize:'12px',fontWeight:600}}>GPU Accelerated</span>
</div>

<CardGroup cols={3}>
  <Card title="GPU" icon="bolt">Processing Engine</Card>
  <Card title="NV12_Q08C" icon="file-video">Input Format</Card>
  <Card title="MCTF" icon="filter">Noise Reduction</Card>
</CardGroup>

<Note>
  **Platform Scope:**<br />
  SW TNR / MCTF is enabled only for **IQ-9075-EVK** and **IQ-8275-EVK**.
</Note>

***

## 01 · What Is It?

**Motion Compensated Temporal Filtering** - a software-based video quality filter that reduces noise across frames — runs on the GPU where IPE hardware MCTF is unavailable.

MCTF improves preview and video quality by reducing temporal noise and enhancing motion clarity. The SW implementation runs on the **GPU**, performing inter-frame blending in static regions and applying global motion compensation transforms.

<img src="https://mintcdn.com/qualcomm-prod/mGpYCfBsZaJSFIEo/Technologies/Camera/images/swmctf.png?fit=max&auto=format&n=mGpYCfBsZaJSFIEo&q=85&s=0d16f06c55af1de40ac1da1ea093f24e" style={{borderRadius:'8px', marginBottom:'24px', width:'100%'}} width="511" height="229" data-path="Technologies/Camera/images/swmctf.png" />

***

## 02 · What It Controls

```
SW MCTF Workflow Pipeline:
Current Frame  →  ME Matrix  →  Warp (prev frame)  →  Alpha Mask  →  Blend  →  Output Frame
Previous Output →  Noise Calc  →  Blend Input  ↗
```

| Stage                  | What it does                                                       | Impact if skipped                                   |
| ---------------------- | ------------------------------------------------------------------ | --------------------------------------------------- |
| Motion Estimation (ME) | Calculates transform matrix between current and previous frame     | No motion compensation → ghosting artifacts         |
| Warp                   | Warps previous output frame using ME matrix                        | Misaligned blend → smearing                         |
| Alpha Mask             | Classifies background vs. local motion regions                     | Static noise not reduced, moving areas over-blended |
| Blend                  | Merges current + previous frames using alpha mask + noise estimate | Temporal noise visible in output video              |

***

<Tip>
  For high-motion scenarios (robotics, automotive), reducing MCTF blend strength prevents temporal ghosting on fast-moving objects.
</Tip>

***

## 03 · Validation

<Note>
  Connect to the device console using SSH. See [How To SSH?](https://dragonwingdocs.qualcomm.com/Linux/devices/iq9075-evk/set-up-the-device#connect-over-ssh) for instructions.
</Note>

<Steps>
  <Step title="Collect user log">
    Monitor the CamX core configuration status in real-time.

    ```bash Log Collection theme={null}
    # On device console
    journalctl -f > /opt/user_log.txt
    ```
  </Step>

  <Step title="Collect kernel log">
    Capture ISP hardware manager events and acquisition info.

    ```bash Kernel Logging theme={null}
    dmesg -w > /opt/kernel_log.txt
    ```
  </Step>

  <Step title="Run GStreamer pipeline with sw-tnr=true">
    Execute the pipeline using the `NV12_Q08C` format and enable the software TNR flag.

    ```bash GStreamer (SW MCTF Enablement) theme={null}
    gst-launch-1.0 -e qtiqmmfsrc name=camsrc video_0::type=preview sw-tnr=true ! \
    video/x-raw,format=NV12_Q08C,width=1280,height=720,framerate=30/1 ! \
    v4l2h264enc capture-io-mode=4 output-io-mode=5 \
    extra-controls="controls,video_bitrate=6000000,video_bitrate_mode=0;" ! \
    h264parse ! mp4mux ! filesink location=/opt/cam_prev.mp4
    ```
  </Step>

  <Step title="Verify log output">
    Confirm the feature is active by checking these exact log entries in the user log:

    **CamX pipeline status:**

    ```text User Log Verification theme={null}
    CamX: [CORE_CFG] 3509 3556 [CORE] camxpipeline.h:4222 SetPipelineStatus()
    RealTimeFeatureZSLPreviewRawSWMCTF_0_cam_0 status is now PipelineStatus::STREAM_ON
    ```

    **MCTF library initialization:**

    ```text User Log Verification theme={null}
    CamX: [ INFO] 3509 3556 [CHI ] camxchimoduleswmctf.cpp:328 Initialize()
    libmctf Version: 1.0.0
    ```

    <Tip>
      `STREAM_ON` confirms the CamX pipeline is live with MCTF enabled. The `libmctf Version` string confirms the software library is initialized on the GPU.
    </Tip>
  </Step>
</Steps>

## 🛠️ Troubleshooting / Known Issues — SW TNR/MCTF

| Issue / Observation                       | Details / Notes                                                                                                                                             |
| ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Ghosting artifacts on fast-moving objects | High-motion scenarios (robotics, automotive) can cause temporal ghosting — reduce MCTF blend strength to mitigate                                           |
| `STREAM_ON` status not seen in user log   | CamX pipeline may not be live with MCTF enabled — verify log entry: `SetPipelineStatus() ... status is now PipelineStatus::STREAM_ON`                       |
| `libmctf` library not initialized         | If `libmctf Version: 1.0.0` is absent from user log, the SW MCTF library failed to initialize on the GPU — check `camxchimoduleswmctf.cpp:328 Initialize()` |
