Opened 16 years ago

Closed 15 years ago

Last modified 14 years ago

#4872 closed enhancement (fixed)

Detect if video is letterboxed and switch to corect fill mode

Reported by: Mårten <mabo@…> Owned by: Janne Grunau
Priority: minor Milestone: 0.22
Component: mythtv Version: head
Severity: medium Keywords: 16:9 full half automatic detect letterbox half full
Cc: Rob Smith Ticket locked: yes

Description (last modified by Rob Smith)

This patch scans each frame for black bars on the top and bottom. If black bars are detected it switches to Full or Half fill mode (to the one that is most appropriate). It also switch off the fill mode if the letterbox disappears.

This is useful if you have a 16:9 display and view content that is letterboxed.

To enable this feature by default go to Setup->TV Settings->Playback->Next->Zoom and select "Auto Detect (Default Off)"

Or to just try it out you can enable it from the "Adjust Fill" menu.

Attachments (10)

detectLetterboxV5.patch (15.5 KB) - added by Mårten <mabo@…> 16 years ago.
Patch to autodetect letterbox for release-0-21-fixes rev :16402
detectLetterboxV6.patch (21.1 KB) - added by Mårten <mabo@…> 16 years ago.
New version including bug fixes and use pre-buffered frames for detection (patch for 21-fixes branch)
detectLetterboxV7.patch (17.2 KB) - added by Mårten <mabo@…> 16 years ago.
Same as v6 but all debug code is removed.
detectLetterboxV7_widescreen_backswitch_fix.patch (17.7 KB) - added by ich@… 16 years ago.
This modified version of the v7 patch switches any zoom mode off if the source already is widescreen. This is needed for e.g. when switching from a 4:3 zoomed letterbox source to a 16:9 source (the original v7 patch would leave the 16:9 source zoomed)
detectLetterboxV8.patch (17.5 KB) - added by Rob Smith 15 years ago.
Updated V7 + widescreen backswitch fix to work with current trunk ([18991])
detectLetterboxV9.patch (22.4 KB) - added by Rob Smith 15 years ago.
Updated V8, encapsulation of the detection code and partial vdpau implementation
detectLetterboxV10.patch (27.9 KB) - added by Rob Smith 15 years ago.
V9 minus the (nonfunctional) vdpau bits and updated to work with r20145
detectLetterboxV11.patch (27.9 KB) - added by Rob Smith 15 years ago.
v10 updated to r20240
detectLetterboxV12.patch (27.6 KB) - added by Rob Smith 15 years ago.
Updated for r21047
detectLetterboxV13.patch (20.2 KB) - added by Rob Smith 15 years ago.

Download all attachments as: .zip

Change History (33)

Changed 16 years ago by Mårten <mabo@…>

Attachment: detectLetterboxV5.patch added

Patch to autodetect letterbox for release-0-21-fixes rev :16402

comment:1 Changed 16 years ago by danielk

Version: 0.21-fixeshead

comment:2 Changed 16 years ago by Mark Buechler <Mark.Buechler@…>

You may want to do something around your VERBOSE messages with frame->codec != ... and sourceAspect > 15 ... Those will get logged several times a second should they be true.

  • Mark.

comment:3 Changed 16 years ago by davilla@…

How about also moving the boolean test for isDetectLetterbox outside the routine and use it to trap the call to DetectLetterbox? so that 15 lines of initialization code and the call/return does not execute if this feature is not enabled.

comment:4 Changed 16 years ago by Rob Smith

Any chance this can be also used with the internal video player (mythvideo)?

comment:5 Changed 16 years ago by Rob Smith

I retract my statement, I was using a really screwed up video. My mistake.

Changed 16 years ago by Mårten <mabo@…>

Attachment: detectLetterboxV6.patch added

New version including bug fixes and use pre-buffered frames for detection (patch for 21-fixes branch)

Changed 16 years ago by Mårten <mabo@…>

Attachment: detectLetterboxV7.patch added

Same as v6 but all debug code is removed.

comment:6 Changed 16 years ago by Mårten <mabo@…>

I think that version 7 of this patch is ready for inclusion into trunk.

Changed 16 years ago by ich@…

This modified version of the v7 patch switches any zoom mode off if the source already is widescreen. This is needed for e.g. when switching from a 4:3 zoomed letterbox source to a 16:9 source (the original v7 patch would leave the 16:9 source zoomed)

comment:7 Changed 16 years ago by wdirksen@…

Hello Guys,

I'm a little new to linux but a big fan of MythTV. I have tried to research how to apply a patch in Linux, but I can't get this patch to compile. So I have the following newbie questions:

1 In which directory do I patch this? 2 Which syntax in the PATCH command should I use?

Thanks! Wessel

System: Mythbuntu 8.04 AMD-64

AMD Athlon-64 3500, NVidia 8500 GT, nForce 4, 3GB RAM, 2x Hauppauge PVR-150

comment:8 Changed 16 years ago by tino.keitel+mythtv@…

Hi,

I tested detectLetterboxV7_widescreen_backswitch_fix.patch with 0.21-fixes SVN 17453.

I have a 16:10 TFT and use DVB-T. I have the problem that the autodetection switched to full zoom mode instead of half, which hides a part of the picture.

comment:9 Changed 16 years ago by tino.keitel+mythtv@…

I replaced all occurrences of kAdjustFill_Full with kAdjustFill_Half and now it works.

I never knew hat those "half" and "full" thingies stand for. From glancing at the code, it seems to be for 14:9 and 16:9 screens. Well, what about the folks with other screens, like 16:10?

It looks to me that the best solution (i.e. screen aspect ratio independent) would be a "zoom to full screen width, if the black borders on the upper and lower edge allow it"

The impact of the current implementatio is that it seems to confuse my 16:10 display with a 16:9 display, and crops the picture at the left and right border by switching to full instead of half.

comment:10 Changed 16 years ago by Rob Smith

Cc: Rob Smith added
Description: modified (diff)

comment:11 Changed 15 years ago by anonymous

any status on this? It would be great if we could get this into current head so that it doesn't become stale and need to be complete re-written.

comment:12 Changed 15 years ago by Jeremy Nickurak <mythtv-bugs@…>

If you can reliably tell what bounding box of the input image actually has content, why would you want to select a full/half mode? Why not simply crop the black bars (wherever they are in the image), and scale the image to either fit the entire image to the monitor, or fill the entire monitor with the image?

Changed 15 years ago by Rob Smith

Attachment: detectLetterboxV8.patch added

Updated V7 + widescreen backswitch fix to work with current trunk ([18991])

comment:13 Changed 15 years ago by Rob Smith

For all those of you wondering bout cpu usage:

<janneg>        kormoc: with yadif as deinterlacing NuppelVideoPlayer::DetectLetterbox() takes 0.2 percent
<janneg>        without deinterlacer it's 0.8 percent
<janneg>        for 720x576 mpeg2
<janneg>        with h264 hd it's less than 0.01 percent which I don't really understand
<janneg>        probably scaling since decoding is so much more expensive

comment:14 Changed 15 years ago by brian@…

Any chance at all this will land on the trunk? Without having actually tried the patch, this sounds like a great feature!

Changed 15 years ago by Rob Smith

Attachment: detectLetterboxV9.patch added

Updated V8, encapsulation of the detection code and partial vdpau implementation

comment:15 Changed 15 years ago by Rob Smith

I can't finish working on the VDPAU support right now, so if anyone else wants to take up the torch until I can finish it?

Changed 15 years ago by Rob Smith

Attachment: detectLetterboxV10.patch added

V9 minus the (nonfunctional) vdpau bits and updated to work with r20145

Changed 15 years ago by Rob Smith

Attachment: detectLetterboxV11.patch added

v10 updated to r20240

comment:16 Changed 15 years ago by anonymous

Any way to get this committed? I'd love to see this feature, but I only run prebuilt packages (I'm not ready to take the leap to compiling my own myth). If it could be put in 0.22 (whenever that gets released) that would be awesome!!

comment:17 Changed 15 years ago by blazej.lewcio@…

Big thanks for implementing this patch. It works really really cool!

I think it would be very useful to make it a bit more configurable. I think about an option to set properties for the two states: 0) Letter box not detected 1) Letter box detected

My example scenario is as follow: 0) For normal non-letter-boxed content, I would like to automaticaly change only the aspect ratio to 16:9, but turn off the zoom. 1) For letter-boxed content, the zoom should be activated (like it works now), and the aspect ratio should set to Off.

It would improve the usability if users could adapt the settings according to their needs.

comment:18 Changed 15 years ago by anonymous

This patch no longer applies against trunk without modification, mostly whitepsace. There were however a few changes that had to be made due to the code arround the patchsite in a file changed. After this the patch applied reletivly clean, there were some offset messages and even a fuzzy. However, it nolonger actually does what it says it does. Myth will compile but turning on the feature this adds does nothing. Might be related to the FFmpeg sync.

Changed 15 years ago by Rob Smith

Attachment: detectLetterboxV12.patch added

Updated for r21047

Changed 15 years ago by Rob Smith

Attachment: detectLetterboxV13.patch added

comment:19 Changed 15 years ago by Janne Grunau

Milestone: unknown0.22
Owner: changed from Isaac Richards to Janne Grunau
Status: newaccepted

comment:20 Changed 15 years ago by Janne Grunau

Resolution: fixed
Status: acceptedclosed

(In [21472]) auto letterbox detection. Fixes #4872

detects letter/pillar box and sets the fill mode accordingly works only with software decoding

patch by: Mårten <mabo mochc net>

comment:21 Changed 15 years ago by Janne Grunau

(In [21490]) remove unecessary include from DetectLetterbox?.cpp, fixes compilation without X

Fixes #6902, Refs #4872

comment:22 Changed 14 years ago by macbeth@…

It is possible modify this patch to allow also the zoom on 16:9 content when displayed on 4:3 tv ?

comment:23 Changed 14 years ago by robertm

Ticket locked: set
Note: See TracTickets for help on using tickets.