[mythtvnz] CPU required for Freeview HD

Robert (mythTV) mythtv at isolutions.co.nz
Wed Aug 20 15:17:42 BST 2008


Graeme Woollett wrote:
 > Is there _anyone_ on this list that is able to watch TV3 1080i  with 
no stuttering and using software de-interlacing, if so what CPU do you have?

I've just built up a (cheaper) mythTV box for myself which is proving 
more than adequate with only a few caveats:

Build Spec:
- Silverstone Grandia GD02B Black mATX Case
- Abit I-N73HD nVidia 630i Motherboard (onboard nVidia 7100, HDMI & 
SPDIF Optical)
- Intel Core 2 Duo E7200 Dual Core 3MB L2 2.53GHz
- 2Gb Generic RAM (Single Stick)
- Nova-T 500 PCI Dual DVB-T Tuner (Using the remote for mythTV control)
- Leadtek Winfast 2000XP Deluxe (Analog Tuner - for Prime)
- 2 x Western Digital 1TB SATA 7200rpm
- ASUS LightScribe DVD R/W
- Logitech Quickcam, USB Multi-Card Reader, Wireless Keyboard, Mouse, etc.

I'm able to watch TV3 (any channel) without any stuttering, and with no 
real issues ... although, I am cheating a bit while doing this.

I'm using Paul's source, compiled under Mythbuntu 8.04, 32-Bit, and have 
added a few patches of my own into it (from v4l-dvb, and ffmpeg) to try 
to fix some issues, and to try and improve the stability. No luck as 
yet. I believe the crashing is due to ffmpeg/h264 issues, or as outlined 
AC3 audio issues, and not due to mythTV itself.

Also, I've updated mythTV to handle my Leadtek when using the latest 
v4l-dvb, as otherwise I just get a green screen due to the video not 
being initialized. The latest v4l-dvb supports the Quickcam I have, and 
the ffmpeg patches are to try and keep up with the trunk changes/patches 
to see if it helps - not much luck to date.

While I'm also still experiencing random crashes on TV1/TV3, and 
occasionally on other channels, I can watch TV3 using Bob (2x) without 
issue.


CPU Load for me is around 50% - 80% on a single core, depending on 
source/content/channel. I do not ever have the CPU pegged with this setup.


Paul wrote:
 > I might also look at adding a setting do disable the loop_filter 
which should make border-line machines capable.

(P.S> Thanks Paul for all your hard work & shenanigans!)

The 'tricks' I've employed to get this to work are adjusting the 
loop_filter setting, and picking the best de-interlacer for the 
resolution/source required.

Taking the idea from Mike Russel a bit further I did the following:


libs/libmythtv/avformatdecoder.cpp

     video_codec_id = kCodec_MPEG2; // default to MPEG2
     }

+    if (CODEC_ID_H264 == enc->codec_id)
+    {
+        if (height > 720)
+        {
+            VERBOSE(VB_IMPORTANT, LOC << "Loop Filter set to discard 
all except Key Frames [" << width << "," << height << "]");
+            enc->skip_loop_filter = AVDISCARD_NONKEY;
+        }
+        else if (height > 576)
+        {
+            VERBOSE(VB_IMPORTANT, LOC << "Loop Filter set to discard 
all Bi-directional Frames [" << width << "," << height << "]");
+            enc->skip_loop_filter = AVDISCARD_BIDIR;
+        }
+        else
+        {
+            VERBOSE(VB_IMPORTANT, LOC << "Loop Filter set to default 
(discard Zero Frames) [" << width << "," << height << "]");
+            enc->skip_loop_filter = AVDISCARD_DEFAULT;
+        }
+    }

      if (enc->codec)
      {


While this is a real HACK, in this way the degree of skipping set in the 
loop filter is dynamically controlled based on the (presumed) load which 
would come from the TV Channels.

For TV3 @ 1080i = 1920x1088 - this turns off the loop filter (drop as 
much as possible)
For all 720p channels, it turns off the Bi-Directional Frames (enough 
CPU load dropped)
For all 576i channels, it leaves the loop filter fully enabled (best 
quality)

Also, for the TV Playback profile, I've specified the following (in a 
new 'Freeview' setting):

ALL: standard, 2 CPUs, xv-blit, softblend, no filters
    == 720 x 576, Yadif (2x) / Linear Blend (for 576i)
    > 1280 x 720, Bob (2x) / Linear Blend (for 1080i)
    > 0 x 0, None / None (for 720p, and my Analog Card)

For the Analog Card, I also 'cheat' again and do the following:
    Recording Profile -> Software Encoder -> Live TV
    - Capture at 768 x 576, High Quality, MPEG 4, 3200 kbps, High 
Quality, MP3, 48kHz

Then for each channel on the Analog Card, I add in a Video Filter: 
(depending on noise)
    - linearblend,denoise3d
    - linearblend,denoise3d=12

This has the effect of de-interlacing and de-noising the analog channels 
BEFORE being encoded by the MPEG4 encoder, which actually results in a 
much lower CPU load for analog recording, much better recordings as a 
result, and provides a resultant resolution which falls into the '0 x 0' 
category above, thereby not running the de-interlacing twice, and only 
applying the de-noising filtering on the analog channels as required.


In this way I get this as a result:

576i Analog = TV -> linearblend -> denoise3d -> MPEG4/MP3 HQ -> 768 x 
576 (square pixels)
576i Digital = H.264 -> Yadif (2x) -> 720 x 576
720p Digital = H.264 -> 1280 x 720 (with Bi-Dir Loop Filtering Off)
1080i Digital = H.264 -> Bob (2x) -> 1920 x 1088 (with no Loop Filtering)

CPU Load for any channel is now 'mitigated' to always be well within the 
single core decoding limits. Where there is more data (and more display 
quality), the reduction in CPU load for the removed loop filtering is 
made up for in the resolution being displayed.

Works for me ... :-)


Oh, and if you need analog card support and want to use the latest 
v4l-dvb git or the pre-built v4l-dvb from Martin Pitt you'll need the 
following:

/libs/libmythtv/NuppelVideoRecorder.cpp

-    if (driver == "cx8800" || driver == "go7007" || driver == "em28xx")
+   if (driver == "cx8800" || driver == "go7007" || driver == "em28xx" 
|| driver == "bttv")

Or, (in theory) you could comment out the line entirely ... but not 100% 
sure about that.


One last thing ... To ensure that I don't have CPU throttling issues 
(since I've noticed the load bouncing between cores sometimes), and this 
seems to cause some jitter as cores 'speed up' to try and finish 
decoding the frame. I have therefore adjusted the power manager as follows:

/etc/defaults/powernowd
OPTIONS="-q -l 10 -u 20"

This sets the upper bound for frequency up-shift to 20% and the lower 
bound down-shift to 10%. So, basically if your machine ever goes above 
20% (i.e. when playing mythTV), it'll sit at full-speed, and grind 
through everything regardless - for both cores. Once you return to idle 
though, the CPU still returns to lower power state, and idles nicely and 
cooler.


Whew ... enough typing for tonight ...

-- Robert.




More information about the mythtvnz mailing list