Ticket #4872: detectLetterboxV12.patch
File detectLetterboxV12.patch, 27.6 KB (added by , 15 years ago) |
---|
-
mythtv/libs/libmythtv/NuppelVideoPlayer.cpp
31 31 #include "mythdbcon.h" 32 32 #include "dialogbox.h" 33 33 #include "NuppelVideoPlayer.h" 34 #include "DetectLetterbox.h" 34 35 #include "audiooutput.h" 35 36 #include "recordingprofile.h" 36 37 #include "osdtypes.h" … … 275 276 // Debugging variables 276 277 output_jmeter(NULL) 277 278 { 279 280 // Playback (output) zoom control 281 detect_letter_box = new DetectLetterbox(this); 282 278 283 vbimode = VBIMode::Parse(gContext->GetSetting("VbiFormat")); 279 284 280 285 commrewindamount = gContext->GetNumSetting("CommRewindAmount",0); … … 1445 1450 buffer->timecode = timecode; 1446 1451 1447 1452 videoOutput->ReleaseFrame(buffer); 1453 1454 detect_letter_box->Detect(buffer); 1448 1455 } 1449 1456 1450 1457 /** \fn NuppelVideoPlayer::DiscardVideoFrame(VideoFrame*) … … 2907 2914 // handle scan type changes 2908 2915 AutoDeint(frame); 2909 2916 2917 detect_letter_box->SwitchTo(frame); 2918 2910 2919 FrameScanType ps = m_scan; 2911 2920 if (kScan_Detect == m_scan || kScan_Ignore == m_scan) 2912 2921 ps = kScan_Progressive; … … 5320 5329 { 5321 5330 if (videoOutput) 5322 5331 { 5332 detect_letter_box->SetDetectLetterbox(false); 5323 5333 videoOutput->ToggleAdjustFill(adjustfillMode); 5324 5334 ReinitOSD(); 5325 5335 } -
mythtv/libs/libmythtv/DetectLetterbox.cpp
1 // -*- Mode: c++ -*- 2 3 // Qt headers 4 #include <QApplication> 5 #include <QKeyEvent> 6 7 // MythTV headers 8 #include "DetectLetterbox.h" 9 #include "NuppelVideoPlayer.h" 10 #include "videoouttypes.h" 11 #include "videoout_xv.h" 12 13 DetectLetterbox::DetectLetterbox(NuppelVideoPlayer* const nvp) 14 { 15 int dbAdjustFill = gContext->GetNumSetting("AdjustFill", 0); 16 isDetectLetterbox = dbAdjustFill >= kAdjustFill_AutoDetect_DefaultOff; 17 detectLetterboxDefaultMode = (AdjustFillMode) max((int) kAdjustFill_Off, 18 dbAdjustFill - kAdjustFill_AutoDetect_DefaultOff); 19 detectLetterboxSwitchFrame = -1; 20 detectLetterboxPossibleHalfFrame = -1; 21 detectLetterboxPossibleFullFrame = -1; 22 detectLetterboxDetectedMode = nvp->GetAdjustFill(); 23 detectLetterboxLimit = gContext->GetNumSetting("DetectLeterboxLimit", 75); 24 nupple_video_player = nvp; 25 } 26 27 DetectLetterbox::~DetectLetterbox() 28 { 29 } 30 31 /** \fn DetectLetterbox::Detect(VideoFrame*) 32 * \brief Detects if this frame is or is not letterboxed 33 * 34 * If a change is detected detectLetterboxSwitchFrame and 35 * detectLetterboxDetectedMode are set. 36 */ 37 void DetectLetterbox::Detect(VideoFrame *frame) 38 { 39 unsigned char *buf = frame->buf; 40 int *pitches = frame->pitches; 41 int *offsets = frame->offsets; 42 const int width = frame->width; 43 const int height = frame->height; 44 const long long frameNumber = frame->frameNumber; 45 const int NUMBER_OF_DETECTION_LINES = 3; // How many lines are we looking at 46 const int THRESHOLD = 5; // Y component has to not vary more than this in the bars 47 const int HORIZONTAL_THRESHOLD = 4; // How tolerant are we that the image has horizontal edges 48 49 // If the black bars is larger than this limit we switch to Half or Full Mode 50 // const int fullLimit = (int) (((height - width * 9 / 16) / 2) * detectLetterboxLimit / 100); 51 // const int halfLimit = (int) (((height - width * 9 / 14) / 2) * detectLetterboxLimit / 100); 52 // If the black bars is larger than this limit we switch to Half or Full Mode 53 const int fullLimit = (int) ((height * (1 - nupple_video_player->GetVideoAspect() * 9 / 16) / 2) * detectLetterboxLimit / 100); 54 const int halfLimit = (int) ((height * (1 - nupple_video_player->GetVideoAspect() * 9 / 14) / 2) * detectLetterboxLimit / 100); 55 56 const int xPos[] = {width / 4, width / 2, width * 3 / 4}; // Lines to scan for black letterbox edge 57 int topHits = 0, bottomHits = 0, minTop = 0, minBottom = 0, maxTop = 0, maxBottom = 0; 58 int topHit[] = {0, 0, 0}, bottomHit[] = {0, 0, 0}; 59 60 if (!GetDetectLetterbox()) 61 return; 62 63 if (!nupple_video_player->getVideoOutput()) 64 return; 65 66 switch (frame->codec) { 67 case FMT_YV12: 68 if (frameNumber == 1) 69 VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: YV12 frame format detected")); 70 break; 71 default: 72 VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: The source is not a supported frame format (was %1)").arg(frame->codec)); 73 isDetectLetterbox = false; 74 return; 75 } 76 77 if (frameNumber < 0) 78 { 79 VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: Strange frame number %1").arg(frameNumber)); 80 return; 81 } 82 83 if (nupple_video_player->GetVideoAspect() > 1.5) 84 { 85 if (detectLetterboxDetectedMode != detectLetterboxDefaultMode) 86 { 87 VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: The source is already in widescreen (aspect: %1)").arg(nupple_video_player->GetVideoAspect())); 88 detectLetterboxLock.lock(); 89 detectLetterboxConsecutiveCounter = 0; 90 detectLetterboxDetectedMode = detectLetterboxDefaultMode; 91 detectLetterboxSwitchFrame = frameNumber; 92 detectLetterboxLock.unlock(); 93 } 94 else 95 { 96 detectLetterboxConsecutiveCounter++; 97 } 98 VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: The source is already in widescreen (aspect: %1)").arg(nupple_video_player->GetVideoAspect())); 99 isDetectLetterbox = false; 100 return; 101 } 102 103 // Establish the level of light in the edge 104 int averageY = 0; 105 for (int detectionLine = 0; detectionLine < NUMBER_OF_DETECTION_LINES; detectionLine++) 106 { 107 averageY += buf[offsets[0] + 5 * pitches[0] + xPos[detectionLine]]; 108 averageY += buf[offsets[0] + (height - 6) * pitches[0] + xPos[detectionLine]]; 109 } 110 averageY /= NUMBER_OF_DETECTION_LINES * 2; 111 if (averageY > 64) // To bright to be a letterbox border 112 averageY = 0; 113 114 // Scan the detection lines 115 for (int y = 5; y < height / 4; y++) // skip first pixels incase of noise in the edge 116 { 117 for (int detectionLine = 0; detectionLine < NUMBER_OF_DETECTION_LINES; detectionLine++) 118 { 119 int Y = buf[offsets[0] + y * pitches[0] + xPos[detectionLine]]; 120 int U = buf[offsets[1] + (y>>1) * pitches[1] + (xPos[detectionLine]>>1)]; 121 int V = buf[offsets[2] + (y>>1) * pitches[2] + (xPos[detectionLine]>>1)]; 122 if ((!topHit[detectionLine]) && 123 ( Y > averageY + THRESHOLD || Y < averageY - THRESHOLD || 124 U < 128 - 32 || U > 128 + 32 || 125 V < 128 - 32 || V > 128 + 32 )) 126 { 127 topHit[detectionLine] = y; 128 topHits++; 129 if (!minTop) 130 minTop = y; 131 maxTop = y; 132 } 133 134 Y = buf[offsets[0] + (height-y-1 ) * pitches[0] + xPos[detectionLine]]; 135 U = buf[offsets[1] + (height-y-1 >> 1) * pitches[1] + (xPos[detectionLine]>>1)]; 136 V = buf[offsets[2] + (height-y-1 >> 1) * pitches[2] + (xPos[detectionLine]>>1)]; 137 if ((!bottomHit[detectionLine]) && 138 ( Y > averageY + THRESHOLD || Y < averageY - THRESHOLD || 139 U < 128 - 32 || U > 128 + 32 || 140 V < 128 - 32 || V > 128 + 32 )) 141 { 142 bottomHit[detectionLine] = y; 143 bottomHits++; 144 if (!minBottom) 145 minBottom = y; 146 maxBottom = y; 147 } 148 } 149 150 if (topHits == NUMBER_OF_DETECTION_LINES && bottomHits == NUMBER_OF_DETECTION_LINES) 151 { 152 break; 153 } 154 } 155 if (topHits != NUMBER_OF_DETECTION_LINES) maxTop = height / 4; 156 if (!minTop) minTop = height / 4; 157 if (bottomHits != NUMBER_OF_DETECTION_LINES) maxBottom = height / 4; 158 if (!minBottom) minBottom = height / 4; 159 160 bool horizontal = ((minTop && maxTop - minTop < HORIZONTAL_THRESHOLD) && 161 (minBottom && maxBottom - minBottom < HORIZONTAL_THRESHOLD)); 162 163 if (detectLetterboxSwitchFrame > frameNumber) // user is reversing 164 { 165 detectLetterboxLock.lock(); 166 detectLetterboxDetectedMode = nupple_video_player->GetAdjustFill(); 167 detectLetterboxSwitchFrame = -1; 168 detectLetterboxPossibleHalfFrame = -1; 169 detectLetterboxPossibleFullFrame = -1; 170 detectLetterboxLock.unlock(); 171 } 172 173 if (minTop < halfLimit || minBottom < halfLimit) 174 detectLetterboxPossibleHalfFrame = -1; 175 if (minTop < fullLimit || minBottom < fullLimit) 176 detectLetterboxPossibleFullFrame = -1; 177 178 if (detectLetterboxDetectedMode != kAdjustFill_Full) 179 { 180 if (detectLetterboxPossibleHalfFrame == -1 && 181 minTop > halfLimit && minBottom > halfLimit) { 182 detectLetterboxPossibleHalfFrame = frameNumber; 183 } 184 } 185 else 186 { 187 if (detectLetterboxPossibleHalfFrame == -1 && 188 minTop < fullLimit && minBottom < fullLimit) { 189 detectLetterboxPossibleHalfFrame = frameNumber; 190 } 191 } 192 if (detectLetterboxPossibleFullFrame == -1 && minTop > fullLimit && minBottom > fullLimit) 193 detectLetterboxPossibleFullFrame = frameNumber; 194 195 if ( maxTop < halfLimit || maxBottom < halfLimit) // Not to restrictive when switching to off 196 { 197 // No Letterbox 198 if (detectLetterboxDetectedMode != detectLetterboxDefaultMode) 199 { 200 VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: Non Letterbox detected on line: %1 (limit: %2)").arg(min(maxTop, maxBottom)).arg(halfLimit)); 201 detectLetterboxLock.lock(); 202 detectLetterboxConsecutiveCounter = 0; 203 detectLetterboxDetectedMode = detectLetterboxDefaultMode; 204 detectLetterboxSwitchFrame = frameNumber; 205 detectLetterboxLock.unlock(); 206 } 207 else 208 { 209 detectLetterboxConsecutiveCounter++; 210 } 211 } 212 else if (horizontal && minTop > halfLimit && minBottom > halfLimit && 213 maxTop < fullLimit && maxBottom < fullLimit) 214 { 215 // Letterbox (with narrow bars) 216 if (detectLetterboxDetectedMode != kAdjustFill_Half) 217 { 218 VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: Narrow Letterbox detected on line: %1 (limit: %2) frame: %3").arg(minTop).arg(halfLimit).arg(detectLetterboxPossibleHalfFrame)); 219 detectLetterboxLock.lock(); 220 detectLetterboxConsecutiveCounter = 0; 221 if (detectLetterboxDetectedMode == kAdjustFill_Full && 222 detectLetterboxSwitchFrame != -1) { 223 // Do not change switch frame if switch to Full mode has not been executed yet 224 } 225 else 226 detectLetterboxSwitchFrame = detectLetterboxPossibleHalfFrame; 227 detectLetterboxDetectedMode = kAdjustFill_Half; 228 detectLetterboxLock.unlock(); 229 } 230 else 231 { 232 detectLetterboxConsecutiveCounter++; 233 } 234 } 235 else if (horizontal && minTop > fullLimit && minBottom > fullLimit) 236 { 237 // Letterbox 238 detectLetterboxPossibleHalfFrame = -1; 239 if (detectLetterboxDetectedMode != kAdjustFill_Full) 240 { 241 VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: Detected Letterbox on line: %1 (limit: %2) frame: %2").arg(minTop).arg(fullLimit).arg(detectLetterboxPossibleFullFrame)); 242 detectLetterboxLock.lock(); 243 detectLetterboxConsecutiveCounter = 0; 244 detectLetterboxDetectedMode = kAdjustFill_Full; 245 detectLetterboxSwitchFrame = detectLetterboxPossibleFullFrame; 246 detectLetterboxLock.unlock(); 247 } 248 else 249 { 250 detectLetterboxConsecutiveCounter++; 251 } 252 } 253 else 254 { 255 if (detectLetterboxConsecutiveCounter <= 3) 256 detectLetterboxConsecutiveCounter = 0; 257 } 258 } 259 260 /** \fn DetectLetterbox::SwitchTo(VideoFrame*) 261 * \brief Switch to the mode detected by DetectLetterbox 262 * 263 * Switch fill mode if a switch was detected for this frame. 264 */ 265 void DetectLetterbox::SwitchTo(VideoFrame *frame) 266 { 267 if (!GetDetectLetterbox()) 268 return; 269 270 if (detectLetterboxSwitchFrame != -1) 271 { 272 detectLetterboxLock.lock(); 273 if (detectLetterboxSwitchFrame <= frame->frameNumber && 274 detectLetterboxConsecutiveCounter > 3) 275 { 276 if (nupple_video_player->GetAdjustFill() != detectLetterboxDetectedMode) 277 { 278 VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: Switched to %1 on frame %2 (%3)").arg(detectLetterboxDetectedMode).arg(frame->frameNumber).arg(detectLetterboxSwitchFrame)); 279 nupple_video_player->getVideoOutput()->ToggleAdjustFill(detectLetterboxDetectedMode); 280 nupple_video_player->ReinitOSD(); 281 } 282 detectLetterboxSwitchFrame = -1; 283 } 284 else if (detectLetterboxSwitchFrame <= frame->frameNumber) 285 VERBOSE(VB_PLAYBACK, QString("Detect Letterbox: Not Switched to %1 on frame %2 (%3) Not enough consecutive detections (%4)").arg(detectLetterboxDetectedMode).arg(frame->frameNumber).arg(detectLetterboxSwitchFrame).arg(detectLetterboxConsecutiveCounter)); 286 287 detectLetterboxLock.unlock(); 288 } 289 } 290 291 void DetectLetterbox::SetDetectLetterbox(bool detect) 292 { 293 isDetectLetterbox = detect; 294 detectLetterboxSwitchFrame = -1; 295 detectLetterboxDetectedMode = nupple_video_player->GetAdjustFill(); 296 } 297 298 bool DetectLetterbox::GetDetectLetterbox() 299 { 300 return isDetectLetterbox; 301 } 302 303 /* vim: set expandtab tabstop=4 shiftwidth=4: */ -
mythtv/libs/libmythtv/libmythtv.pro
357 357 # Misc. frontend 358 358 HEADERS += ttfont.h 359 359 SOURCES += ttfont.cpp 360 HEADERS += DetectLetterbox.h 361 SOURCES += DetectLetterbox.cpp 360 362 361 363 using_mheg { 362 364 # DSMCC stuff -
mythtv/libs/libmythtv/tv_play.h
37 37 class OSD; 38 38 class RemoteEncoder; 39 39 class NuppelVideoPlayer; 40 class DetectLetterbox; 40 41 class RingBuffer; 41 42 class ProgramInfo; 42 43 class MythDialog; -
mythtv/libs/libmythtv/DetectLetterbox.h
1 // -*- Mode: c++ -*- 2 3 #include "NuppelVideoPlayer.h" 4 5 using namespace std; 6 7 class NuppelVideoPlayer; 8 9 class MPUBLIC DetectLetterbox 10 { 11 public: 12 DetectLetterbox(NuppelVideoPlayer* const nvp); 13 ~DetectLetterbox(); 14 void SetDetectLetterbox(bool detect); 15 bool GetDetectLetterbox(); 16 void Detect(VideoFrame *frame); 17 void SwitchTo(VideoFrame *frame); 18 19 private: 20 bool isDetectLetterbox; 21 22 AdjustFillMode detectLetterboxDefaultMode; 23 AdjustFillMode detectLetterboxDetectedMode; // Wich mode was last detected 24 long long detectLetterboxSwitchFrame; // On wich frame was the mode switch detected 25 long long detectLetterboxPossibleHalfFrame; 26 long long detectLetterboxPossibleFullFrame; 27 int detectLetterboxConsecutiveCounter; 28 29 NuppelVideoPlayer *nupple_video_player; 30 31 int detectLetterboxLimit; 32 QMutex detectLetterboxLock; 33 }; 34 35 /* vim: set expandtab tabstop=4 shiftwidth=4: */ -
mythtv/libs/libmythtv/NuppelVideoPlayer.h
46 46 struct SwsContext; 47 47 class InteractiveTV; 48 48 class NSAutoreleasePool; 49 class DetectLetterbox; 49 50 50 51 struct TextContainer 51 52 { … … 159 160 void SetBookmark(void); 160 161 void SetKeyframeDistance(int keyframedistance); 161 162 void SetVideoParams(int w, int h, double fps, int keydist, 162 float a = 1.33333, FrameScanType scan = kScan_Ignore, 163 float a = 1.33333, FrameScanType scan = kScan_Ignore, 163 164 bool video_codec_changed = false); 164 165 void SetFileLength(int total, int frames); 165 166 void Zoom(ZoomDirection direction); … … 400 401 { tc_wrap[TC_AUDIO] = 0LL; return tc_wrap[TC_AUDIO]; } 401 402 long long ResyncAudioTimecodeOffset(void) 402 403 { tc_wrap[TC_AUDIO] = LONG_LONG_MIN; return 0L; } 403 long long GetAudioTimecodeOffset(void) const 404 long long GetAudioTimecodeOffset(void) const 404 405 { return tc_wrap[TC_AUDIO]; } 405 406 void SaveAudioTimecodeOffset(long long v) 406 407 { savedAudioTimecodeOffset = v; } … … 414 415 void ActivateDVDButton(void); 415 416 void GoToDVDMenu(QString str); 416 417 void GoToDVDProgram(bool direction); 417 void HideDVDButton(bool hide) 418 void HideDVDButton(bool hide) 418 419 { 419 420 hidedvdbutton = hide; 420 421 } 421 422 423 // Playback (output) zoom automation 424 DetectLetterbox *detect_letter_box; 425 422 426 // Position Map Stuff 423 427 bool PosMapFromEnc(unsigned long long start, 424 428 QMap<long long, long long> &posMap); … … 619 623 long long rewindtime; 620 624 QString m_recusage; 621 625 622 // -- end state stuff -- 626 // -- end state stuff -- 623 627 624 628 625 629 // Input Video Attributes … … 627 631 QSize video_dim; ///< Video (input) buffer width & height 628 632 double video_frame_rate;///< Video (input) Frame Rate (often inaccurate) 629 633 float video_aspect; ///< Video (input) Apect Ratio 630 float forced_video_aspect; 634 float forced_video_aspect; 631 635 /// Video (input) Scan Type (interlaced, progressive, detect, ignore...) 632 636 FrameScanType m_scan; 633 637 /// Set when the user selects a scan type, overriding the detected one … … 780 784 float next_play_speed; 781 785 bool next_normal_speed; 782 786 783 float play_speed; 784 bool normal_speed; 787 float play_speed; 788 bool normal_speed; 785 789 int frame_interval;///< always adjusted for play_speed 786 790 787 int ffrew_skip; 791 int ffrew_skip; 788 792 789 793 // Audio and video synchronization stuff 790 794 VideoSync *videosync; … … 808 812 short int *warplbuff; 809 813 short int *warprbuff; 810 814 int warpbuffsize; 811 815 812 816 // Time Code stuff 813 817 int prevtc; ///< 32 bit timecode if last VideoFrame shown 814 818 int tc_avcheck_framecounter; -
mythtv/libs/libmythtv/tv_play.cpp
28 28 #include "remoteencoder.h" 29 29 #include "remoteutil.h" 30 30 #include "NuppelVideoPlayer.h" 31 #include "DetectLetterbox.h" 31 32 #include "programinfo.h" 32 33 #include "udpnotify.h" 33 34 #include "vsync.h" … … 9724 9725 { 9725 9726 ToggleAdjustFill(actx, (AdjustFillMode) action.right(1).toInt()); 9726 9727 } 9728 else if (action == "AUTODETECT_FILL") 9729 { 9730 actx->nvp->detect_letter_box->SetDetectLetterbox(!actx->nvp->detect_letter_box->GetDetectLetterbox()); 9731 } 9727 9732 else if (action == "GUIDE") 9728 9733 EditSchedule(actx, kScheduleProgramGuide); 9729 9734 else if (action.left(10) == "CHANGROUP_") … … 10315 10320 ctx->UnlockDeleteNVP(__FILE__, __LINE__); 10316 10321 10317 10322 OSDGenericTree *af_item = new OSDGenericTree(treeMenu, tr("Adjust Fill")); 10323 OSDGenericTree *subitem = new OSDGenericTree(af_item, tr("Auto Detect"), 10324 "AUTODETECT_FILL", 10325 (ctx->nvp->detect_letter_box->GetDetectLetterbox()) ? 1 : 0, 10326 NULL, "ADJUSTFILLGROUP"); 10327 10318 10328 for (int i = kAdjustFill_Off; i < kAdjustFill_END; i++) 10319 10329 { 10320 10330 bool sel = (i != kAdjustFill_Off) ? (adjustfill == i) : -
mythtv/libs/libmythtv/videoouttypes.h
56 56 kAdjustFill_Full, 57 57 kAdjustFill_HorizontalStretch, 58 58 kAdjustFill_VerticalStretch, 59 kAdjustFill_END 59 kAdjustFill_END, 60 kAdjustFill_AutoDetect_DefaultOff = 16, 61 kAdjustFill_AutoDetect_DefaultHalf 60 62 } AdjustFillMode; 61 63 62 64 typedef enum LetterBoxColour … … 258 260 case kAdjustFill_Toggle: 259 261 case kAdjustFill_Off: 260 262 case kAdjustFill_END: break; 263 case kAdjustFill_AutoDetect_DefaultOff: ret = QObject::tr("Auto Detect (Default Off)"); break; 264 case kAdjustFill_AutoDetect_DefaultHalf: ret = QObject::tr("Auto Detect (Default Half)"); break; 261 265 } 262 266 263 267 ret.detach(); -
mythtv/libs/libmythtv/videooutbase.cpp
239 239 * vo->ReleaseFrame(frame); // enqueues frame in "used" queue 240 240 * } 241 241 * } 242 * 242 * 243 243 * // In the displaying thread 244 244 * while (playing) 245 245 * { … … 274 274 * update an OSD for example. 275 275 * 276 276 * The VideoBuffers class handles the buffer tracking, 277 * see it for more details on the states a buffer can 277 * see it for more details on the states a buffer can 278 278 * take before it becomes available for reuse. 279 279 * 280 280 * \see VideoBuffers, NuppelVideoPlayer … … 282 282 283 283 /** 284 284 * \fn VideoOutput::VideoOutput() 285 * \brief This constructor for VideoOutput must be followed by an 285 * \brief This constructor for VideoOutput must be followed by an 286 286 * Init(int,int,float,WId,int,int,int,int,WId) call. 287 287 */ 288 288 VideoOutput::VideoOutput() : … … 391 391 if (db_vdisp_profile) 392 392 db_vdisp_profile->SetInput(windows[0].GetVideoDim()); 393 393 394 /* 395 aspectoverride = db_aspectoverride; 396 // If autodection is enabled. Start in the defaultmode 397 adjustfill = db_adjustfill >= kAdjustFill_AutoDetect_DefaultOff ? 398 (AdjustFillMode) (db_adjustfill - kAdjustFill_AutoDetect_DefaultOff) : db_adjustfill; 399 */ 400 401 VideoAspectRatioChanged(aspect); // apply aspect ratio and letterbox mode 402 394 403 return mainSuccess; 395 404 } 396 405 … … 448 457 * \return true if successful, false otherwise. 449 458 * \param overridefilter optional, explicitly use this nondefault deint filter 450 459 */ 451 bool VideoOutput::SetupDeinterlace(bool interlaced, 460 bool VideoOutput::SetupDeinterlace(bool interlaced, 452 461 const QString& overridefilter) 453 462 { 454 463 PIPState pip_state = windows[0].GetPIPState(); … … 472 481 473 482 m_deinterlacing = interlaced; 474 483 475 if (m_deinterlacing) 484 if (m_deinterlacing) 476 485 { 477 486 m_deinterlaceBeforeOSD = true; 478 487 479 488 VideoFrameType itmp = FMT_YV12; 480 489 VideoFrameType otmp = FMT_YV12; 481 490 int btmp; 482 491 483 492 if (db_vdisp_profile) 484 493 m_deintfiltername = db_vdisp_profile->GetFilteredDeint(overridefilter); 485 494 else … … 512 521 } 513 522 } 514 523 515 if (m_deintFilter == NULL) 524 if (m_deintFilter == NULL) 516 525 { 517 526 VERBOSE(VB_IMPORTANT,QString("Couldn't load deinterlace filter %1") 518 527 .arg(m_deintfiltername)); … … 556 565 * All adaptive full framerate deinterlacers require an extra 557 566 * ProcessFrame() call. 558 567 * 559 * \return true if deint name contains doubleprocess 568 * \return true if deint name contains doubleprocess 560 569 */ 561 570 bool VideoOutput::IsExtraProcessingRequired(void) const 562 571 { … … 630 639 db_vdisp_profile->SetInput(windows[0].GetVideoDim()); 631 640 632 641 BestDeint(); 633 642 634 643 DiscardFrames(true); 635 644 636 645 return true; … … 665 674 * \fn VideoOutput::StopEmbedding(void) 666 675 * \brief Tells video output to stop embedding video in an existing window. 667 676 * \sa EmbedInWidget(WId, int, int, int, int) 668 */ 677 */ 669 678 void VideoOutput::StopEmbedding(void) 670 679 { 671 680 windows[0].StopEmbedding(); … … 986 995 const QSize pipVideoDim = pipplayer->GetVideoBufferSize(); 987 996 988 997 // If PiP is not initialized to values we like, silently ignore the frame. 989 if ((video_aspect <= 0) || (pipVideoAspect <= 0) || 998 if ((video_aspect <= 0) || (pipVideoAspect <= 0) || 990 999 (frame->height <= 0) || (frame->width <= 0) || 991 1000 !pipimage || !pipimage->buf || pipimage->codec != FMT_YV12) 992 1001 { … … 1025 1034 1026 1035 sws_scale(pip_scaling_context, img_in.data, img_in.linesize, 0, 1027 1036 piph, img_out.data, img_out.linesize); 1028 1037 1029 1038 if (pipActive) 1030 1039 { 1031 1040 AVPicture img_padded; … … 1038 1047 pip_display_size.height(), 1039 1048 pip_display_size.width(), 1040 1049 PIX_FMT_YUV420P, 10, 10, 10, 10, color); 1041 1050 1042 1051 pipbuf = pip_tmp_buf2; 1043 1052 } 1044 1053 else … … 1064 1073 1065 1074 uint pip_height = pip_tmp_image.height; 1066 1075 uint height[3] = { pip_height, pip_height>>1, pip_height>>1 }; 1067 1076 1068 1077 for (int p = 0; p < 3; p++) 1069 1078 { 1070 1079 for (uint h = 2; h < height[p]; h++) 1071 1080 { 1072 memcpy((frame->buf + frame->offsets[p]) + (h + yoff2[p]) * 1081 memcpy((frame->buf + frame->offsets[p]) + (h + yoff2[p]) * 1073 1082 frame->pitches[p] + xoff2[p], 1074 1083 (pip_tmp_image.buf + pip_tmp_image.offsets[p]) + h * 1075 1084 pip_tmp_image.pitches[p], pip_tmp_image.pitches[p]); … … 1248 1257 * converted to greyscale. 1249 1258 * 1250 1259 * \return 1 if changed, -1 on error and 0 otherwise 1251 */ 1260 */ 1252 1261 int VideoOutput::DisplayOSD(VideoFrame *frame, OSD *osd, int stride, 1253 1262 int revision) 1254 1263 { … … 1312 1321 /** 1313 1322 * \fn VideoOutput::CopyFrame(VideoFrame*, const VideoFrame*) 1314 1323 * \brief Copies frame data from one VideoFrame to another. 1315 * 1324 * 1316 1325 * Note: The frames must have the same width, height, and format. 1317 1326 * \param to The destination frame. 1318 * \param from The source frame 1327 * \param from The source frame 1319 1328 */ 1320 1329 void VideoOutput::CopyFrame(VideoFrame *to, const VideoFrame *from) 1321 1330 { … … 1336 1345 memcpy(to->buf + to->offsets[1], from->buf + from->offsets[1], 1337 1346 from->pitches[1] * (from->height>>1)); 1338 1347 memcpy(to->buf + to->offsets[2], from->buf + from->offsets[2], 1339 from->pitches[2] * (from->height>>1)); 1348 from->pitches[2] * (from->height>>1)); 1340 1349 } 1341 1350 else 1342 1351 { -
mythtv/programs/mythfrontend/globalsettings.cpp
2417 2417 { 2418 2418 HostComboBox *gc = new HostComboBox("AdjustFill"); 2419 2419 gc->setLabel(QObject::tr("Zoom")); 2420 gc->addSelection(toString(kAdjustFill_AutoDetect_DefaultOff), QString::number(kAdjustFill_AutoDetect_DefaultOff)); 2421 gc->addSelection(toString(kAdjustFill_AutoDetect_DefaultHalf), QString::number(kAdjustFill_AutoDetect_DefaultHalf)); 2420 2422 for (int m = kAdjustFill_Off; m < kAdjustFill_END; m++) 2421 2423 gc->addSelection(toString((AdjustFillMode)m), QString::number(m)); 2422 2424 gc->setHelpText(QObject::tr(