[mythtv] [PATCH] Add AFD support for aspect 'magic'
Stuart Auchterlonie
stuarta at squashedfrog.net
Sat Jun 4 21:21:04 UTC 2005
On Sat, Jun 04, 2005 at 03:16:03PM +0100, Neale Swinnerton wrote:
> The Active Format Descriptor (AFD) is set by some broadcasters like ITV1
> and CH4 in the UK in their DVB-T streams. This signals what the format
> of the video is, and along with the aspect ratio of the video stream and
> your display it can resize the video 'better'.
>
> This patch adds support for this to myth. To enable it go to
> Utilities/Setup->Settings->TV Settings->Playback and set aspect override
> to AFD.
>
> When playing back streams that have AFD set you should see the image
> scaled better. ie. it will apply letterboxing/pillarboxing as
> appropriate, Shoot & Protect areas should be honoured.
>
> AFD has some caveats:
> + Only works where the MPEG Stream is either 4:3 or 16:9
> + Only works where your display is either 4:3 or 16:9
>
> Note that if you don't have GuiSizeForTv set the aspect ratio comes from
> the DisplaySize option in your xorg.conf, if GuiSizeForTv is set myth
> calculates the aspect ratio of your screen with the following code
>
> void VideoOutputXv::InitDisplayMeasurements(uint width, uint height)
> {
> <SNIP/>
> int w = DisplayWidth(XJ_disp, XJ_screen_num);
> int h = DisplayHeight(XJ_disp, XJ_screen_num);
> int gui_w = w, gui_h = h;
> gContext->GetResolutionSetting("Gui", gui_w, gui_h);
> if (gui_w)
> w_mm = w_mm * gui_w / w;
> if (gui_h)
> h_mm = h_mm * gui_h / h;
>
> display_aspect = (float)w_mm/h_mm;
> <SNIP/>
> }
>
> w_mm/h_mm is the width/height of your screen in mm as reported by X (ie.
> the values passed via DisplaySize option), for me this means I need a
> gui size of 1024x576 to get my display aspect to 1.78.
>
> I left debug output switched on in the patch, so you will see what value
> myth is calculating for your aspect ratio....
>
> TODO: I'm not sure that the size calculations for the various
> combinations are correct, it seems to work for my limited testing on
> ITV1 / Ch 4. I'm trying to find a test stream to test this out.
I've just had a look at Farscape that was just recorded off BBC3.
It is always a 4:3 picture trasmitted in 16:9 so I figured they
might have stuck an AFD on it.
The lead in 60 seconds is 16:9 proper so we start off with
XJ aspect 1.77778
Display aspect 1.26199
AFD 0
Before: 1280x1024+0+0
VideoOutput::MoveResize:
Img(0,0 720,576)
Disp(0,148 1280,727)
Offset(0,0)
Vscan(0.000000, 0.000000)
DisplayAspect: 1.261993
VideoAspect(1.777778)
XJ_aspect(1.777778)
CDisplayAspect: 1.261993
Letterbox: 7
Then when the program starts I would expect that the AFD would change
to 9 (from the table below) but it doesn't. We get this..
XJ aspect 1.77778
Display aspect 1.26199
AFD 0
Before: 1280x1024+0+0
VideoOutput::MoveResize:
Img(0,0 720,576)
Disp(0,148 1280,727)
Offset(0,0)
Vscan(0.000000, 0.000000)
DisplayAspect: 1.261993
VideoAspect(1.777778)
XJ_aspect(1.777778)
CDisplayAspect: 1.261993
Letterbox: 7
which is identical to before. Then if I cycle through the various
aspect ratios I get the following...
XJ aspect 1.77778
Display aspect 1.26199
AFD 9
Before: 1280x1024+0+0
VideoOutput::MoveResize:
Img(0,0 720,576)
Disp(0,148 1280,727)
Offset(0,0)
Vscan(0.000000, 0.000000)
DisplayAspect: 1.261993
VideoAspect(1.777778)
XJ_aspect(1.777778)
CDisplayAspect: 1.261993
Letterbox: 0
This is on the transition from AFD to OFF in the aspect ratio override.
With a bit more cycling we return to AFD mode with the following
XJ aspect 1.77778
Display aspect 1.26199
AFD 9
Before: 1280x1024+0+0
VideoOutput::MoveResize:
Img(0,0 720,576)
Disp(0,148 1280,727)
Offset(0,0)
Vscan(0.000000, 0.000000)
DisplayAspect: 1.261993
VideoAspect(1.777778)
XJ_aspect(1.777778)
CDisplayAspect: 1.261993
Letterbox: 7
So now the AFD is 9, but still things haven't been stretched out to 4:3.
I'll see what I can work out why it's doing it, but you may have a
better idea off the top of your head.
btw. I don't have a display res setup in the myth database. The output
is just my desktop at 1280x1024
Stuart
>
> +/* Active Format Description(AFD) is set in DVB Streams.
> + * By considering both the aspect ratio and the AFD it
> + * is posible to determine how to present the image in the
> + * correct manner.
> + * See http://www.dtg.org.uk/publications/books/afd.pdf
> + * for the gory details
> + */
> +enum AfdMode {
> + kAfd_Unset = 0,
> + kAfd_Same = 8,
> + kAfd_4_3 = 9,
> + kAfd_16_9 = 10,
> + kAfd_14_9 = 11,
> + kAfd_4_3_Sp_14_9 = 13,
> + kAfd_16_9_Sp_14_9 = 14,
> + kAfd_Sp_4_3 = 15,
> + kAfd_END
> +};
> +
More information about the mythtv-dev
mailing list