Ticket #4046: 4046-v1.patch
File 4046-v1.patch, 38.6 KB (added by , 17 years ago) |
---|
-
libs/libmythtv/util-xv.cpp
81 81 return str; 82 82 } 83 83 84 int colorkey_supported(Display *disp, int port) 84 bool xv_is_attrib_supported( 85 Display *disp, int port, const char *name, 86 int *current_value, int *min_value, int *max_value) 85 87 { 86 88 Atom xv_atom; 87 int colorkey = 0; 89 XvAttribute *attributes; 90 int attrib_count; 88 91 int ret; 89 xv_atom = XInternAtom(disp, "XV_COLORKEY", true); 90 if (xv_atom != None) 92 93 int dummy; 94 int *xv_val = (current_value) ? current_value : &dummy; 95 96 X11S(attributes = XvQueryPortAttributes(disp, port, &attrib_count)); 97 for (int i = (attributes) ? 0 : attrib_count; i < attrib_count; i++) 91 98 { 92 ret = XvGetPortAttribute(disp, port, xv_atom, &colorkey); 93 if (ret != Success) 94 colorkey = 0; 99 if (strcmp(attributes[i].name, name)) 100 continue; 101 102 if (min_value) 103 *min_value = attributes[i].min_value; 104 105 if (max_value) 106 *max_value = attributes[i].max_value; 107 108 X11S(xv_atom = XInternAtom(disp, name, False)); 109 if (None == xv_atom) 110 continue; 111 112 X11S(ret = XvGetPortAttribute(disp, port, xv_atom, xv_val)); 113 if (Success == ret) 114 { 115 X11S(XFree(attributes)); 116 return true; 117 } 95 118 } 96 return colorkey; 119 120 if (attributes) 121 X11S(XFree(attributes)); 122 123 return false; 97 124 } 125 126 bool xv_set_attrib(Display *disp, int port, const char *name, int val) 127 { 128 Atom xv_atom; 129 X11S(xv_atom = XInternAtom(disp, name, False)); 130 if (xv_atom == None) 131 return false; 132 133 int ret; 134 X11S(ret = XvSetPortAttribute(disp, port, xv_atom, val)); 135 if (Success != ret) 136 return false; 137 138 return true; 139 } 140 141 bool xv_get_attrib(Display *disp, int port, const char *name, int &val) 142 { 143 Atom xv_atom; 144 X11S(xv_atom = XInternAtom(disp, name, False)); 145 if (xv_atom == None) 146 return false; 147 148 int ret; 149 X11S(ret = XvGetPortAttribute(disp, port, xv_atom, &val)); 150 if (Success != ret) 151 return false; 152 153 return true; 154 } -
libs/libmythtv/tv_play.h
399 399 int fftime; 400 400 int rewtime; 401 401 int jumptime; 402 bool db_use_picture_attr;403 402 bool smartChannelChange; 404 403 bool MuteIndividualChannels; 405 404 bool arrowAccel; -
libs/libmythtv/openglvideo.h
90 90 void SetVideoResize(const QRect &rect); 91 91 void DisableVideoResize(void); 92 92 int SetPictureAttribute(PictureAttribute attributeType, int newValue); 93 PictureAttributeSupported GetSupportedPictureAttributes(void) const; 93 94 94 95 private: 95 96 void Teardown(void); … … 182 183 void SetVideoResize(const QRect&) { } 183 184 void DisableVideoResize(void) { } 184 185 int SetPictureAttribute(PictureAttribute, int) { return -1; } 186 PictureAttributeSupported GetSupportedPictureAttributes(void) const 187 { return kPictureAttributeSupported_None; } 185 188 }; 186 189 187 190 #endif // !USING_OPENGL_VIDEO -
libs/libmythtv/openglvideo.cpp
1144 1144 return ret; 1145 1145 } 1146 1146 1147 PictureAttributeSupported 1148 OpenGLVideo::GetSupportedPictureAttributes(void) const 1149 { 1150 return (!useColourControl) ? 1151 kPictureAttributeSupported_None : 1152 (PictureAttributeSupported) 1153 (kPictureAttributeSupported_Brightness | 1154 kPictureAttributeSupported_Contrast | 1155 kPictureAttributeSupported_Colour); 1156 } 1157 1147 1158 // locking ok 1148 1159 void OpenGLVideo::SetTextureFilters(vector<GLuint> *textures, int filt) 1149 1160 { -
libs/libmythtv/util-xv.h
24 24 extern bool has_open_xv_port(int port); 25 25 extern uint cnt_open_xv_port(void); 26 26 extern QString xvflags2str(int flags); 27 extern int colorkey_supported(Display *disp, int port); 27 extern bool xv_is_attrib_supported( 28 Display *disp, int port, const char *name, 29 int *current_value = NULL, int *min_val = NULL, int *max_val = NULL); 30 extern bool xv_set_attrib(Display *disp, int port, const char *name, int val); 31 extern bool xv_get_attrib(Display *disp, int port, const char *name, int &val); 28 32 33 29 34 #endif // _UTIL_XV_H_ -
libs/libmythtv/tv_play.cpp
594 594 baseFilters += gContext->GetSetting("CustomFilters"); 595 595 db_time_format = gContext->GetSetting("TimeFormat", "h:mm AP"); 596 596 db_short_date_format = gContext->GetSetting("ShortDateFormat", "M/d"); 597 db_use_picture_attr = gContext->GetNumSetting(598 "UseOutputPictureControls", 0);599 597 smartChannelChange = gContext->GetNumSetting("SmartChannelChange", 0); 600 598 MuteIndividualChannels=gContext->GetNumSetting("IndividualMuteControl", 0); 601 599 arrowAccel = gContext->GetNumSetting("UseArrowAccels", 1); … … 6007 6005 } 6008 6006 } 6009 6007 6008 static PictureAttribute next( 6009 PictureAdjustType type, NuppelVideoPlayer *nvp, PictureAttribute attr) 6010 { 6011 uint sup = kPictureAttributeSupported_None; 6012 if ((kAdjustingPicture_Playback == type) && nvp && nvp->getVideoOutput()) 6013 { 6014 sup = nvp->getVideoOutput()->GetSupportedPictureAttributes(); 6015 if (nvp->getAudioOutput()) 6016 sup |= kPictureAttributeSupported_Volume; 6017 } 6018 else if (kAdjustingPicture_Channel == type) 6019 { 6020 sup = (kPictureAttributeSupported_Brightness | 6021 kPictureAttributeSupported_Contrast | 6022 kPictureAttributeSupported_Colour | 6023 kPictureAttributeSupported_Hue); 6024 } 6025 else if (kAdjustingPicture_Recording == type) 6026 { 6027 sup = (kPictureAttributeSupported_Brightness | 6028 kPictureAttributeSupported_Contrast | 6029 kPictureAttributeSupported_Colour | 6030 kPictureAttributeSupported_Hue); 6031 } 6032 6033 return next((PictureAttributeSupported)sup, attr); 6034 } 6035 6010 6036 void TV::DoTogglePictureAttribute(PictureAdjustType type) 6011 6037 { 6012 if (!db_use_picture_attr && kAdjustingPicture_Playback == type) 6038 PictureAttribute attr = next(type, nvp, adjustingPictureAttribute); 6039 if (kPictureAttribute_None == attr) 6013 6040 return; 6014 6041 6015 adjustingPicture = type; 6042 adjustingPicture = type; 6043 adjustingPictureAttribute = attr; 6016 6044 6017 adjustingPictureAttribute = (PictureAttribute)6018 ((int) adjustingPictureAttribute + 1);6019 if ((adjustingPictureAttribute >= kPictureAttribute_MAX) ||6020 ((type >= kAdjustingPicture_Channel) &&6021 (adjustingPictureAttribute > kPictureAttribute_Hue)))6022 {6023 adjustingPictureAttribute = kPictureAttribute_MIN;6024 }6025 6026 PictureAttribute attr = adjustingPictureAttribute;6027 6045 QString title = toTitleString(type); 6028 6046 6029 6047 if (!GetOSD()) … … 6850 6868 (sel) ? 1 : 0, NULL, "ADJUSTFILLGROUP"); 6851 6869 } 6852 6870 6853 if (db_use_picture_attr) 6871 uint sup = kPictureAttributeSupported_None; 6872 if (nvp && nvp->getVideoOutput()) 6873 sup = nvp->getVideoOutput()->GetSupportedPictureAttributes(); 6874 item = NULL; 6875 for (int i = kPictureAttribute_MIN; i < kPictureAttribute_MAX; i++) 6854 6876 { 6855 item = new OSDGenericTree(treeMenu, tr("Adjust Picture")); 6856 subitem = new OSDGenericTree(item, tr("Brightness"), 6857 "TOGGLEPICCONTROLS" + 6858 QString("%1") 6859 .arg(kPictureAttribute_Brightness)); 6860 subitem = new OSDGenericTree(item, tr("Contrast"), 6861 "TOGGLEPICCONTROLS" + 6862 QString("%1") 6863 .arg(kPictureAttribute_Contrast)); 6864 subitem = new OSDGenericTree(item, tr("Colour"), 6865 "TOGGLEPICCONTROLS" + 6866 QString("%1") 6867 .arg(kPictureAttribute_Colour)); 6868 subitem = new OSDGenericTree(item, tr("Hue"), 6869 "TOGGLEPICCONTROLS" + 6870 QString("%1") 6871 .arg(kPictureAttribute_Hue)); 6877 if (toMask((PictureAttribute)i) & sup) 6878 { 6879 if (!item) 6880 item = new OSDGenericTree(treeMenu, tr("Adjust Picture")); 6881 subitem = new OSDGenericTree( 6882 item, toString((PictureAttribute) i), 6883 QString("TOGGLEPICCONTROLS%1").arg(i)); 6884 } 6872 6885 } 6873 6886 6874 6887 item = new OSDGenericTree(treeMenu, tr("Manual Zoom Mode"), -
libs/libmythtv/videoouttypes.h
68 68 kPictureAttribute_MAX 69 69 } PictureAttribute; 70 70 71 typedef enum PictureAttributeSupported 72 { 73 kPictureAttributeSupported_None = 0x00, 74 kPictureAttributeSupported_Brightness = 0x01, 75 kPictureAttributeSupported_Contrast = 0x02, 76 kPictureAttributeSupported_Colour = 0x04, 77 kPictureAttributeSupported_Hue = 0x08, 78 kPictureAttributeSupported_Volume = 0x10, 79 } PictureAttributeSupported; 80 71 81 inline bool is_interlaced(FrameScanType scan) 72 82 { 73 83 return (kScan_Interlaced == scan) || (kScan_Intr2ndField == scan); … … 212 222 return QDeepCopy<QString>(ret); 213 223 } 214 224 225 inline QString toXVString(PictureAttribute pictureattribute) 226 { 227 QString ret = QString::null; 228 switch (pictureattribute) 229 { 230 case kPictureAttribute_None: break; 231 case kPictureAttribute_Brightness: 232 ret = "XV_BRIGHTNESS"; break; 233 case kPictureAttribute_Contrast: 234 ret = "XV_CONTRAST"; break; 235 case kPictureAttribute_Colour: 236 ret = "XV_SATURATION"; break; 237 case kPictureAttribute_Hue: 238 ret = "XV_HUE"; break; 239 case kPictureAttribute_Volume: 240 case kPictureAttribute_MAX: break; 241 } 242 243 if (ret.isEmpty()) 244 return QString::null; 245 246 return QDeepCopy<QString>(ret); 247 } 248 249 inline QString toString(PictureAttributeSupported supported) 250 { 251 QString ret = ""; 252 253 if (kPictureAttributeSupported_Brightness & supported) 254 ret += "Brightness, "; 255 if (kPictureAttributeSupported_Contrast & supported) 256 ret += "Contrast, "; 257 if (kPictureAttributeSupported_Colour & supported) 258 ret += "Colour, "; 259 if (kPictureAttributeSupported_Hue & supported) 260 ret += "Hue, "; 261 if (kPictureAttributeSupported_Volume & supported) 262 ret += "Volume, "; 263 264 return (ret.isEmpty()) ? "" : ret.left(ret.length() - 2); 265 } 266 267 inline PictureAttributeSupported toMask(PictureAttribute pictureattribute) 268 { 269 PictureAttributeSupported ret = kPictureAttributeSupported_None; 270 switch (pictureattribute) 271 { 272 case kPictureAttribute_None: break; 273 case kPictureAttribute_Brightness: 274 ret = kPictureAttributeSupported_Brightness; break; 275 case kPictureAttribute_Contrast: 276 ret = kPictureAttributeSupported_Contrast; break; 277 case kPictureAttribute_Colour: 278 ret = kPictureAttributeSupported_Colour; break; 279 case kPictureAttribute_Hue: 280 ret = kPictureAttributeSupported_Hue; break; 281 case kPictureAttribute_Volume: 282 ret = kPictureAttributeSupported_Volume; break; 283 case kPictureAttribute_MAX: break; 284 } 285 return ret; 286 } 287 288 inline PictureAttribute next(PictureAttributeSupported supported, 289 PictureAttribute attribute) 290 { 291 int i = ((int) attribute + 1) % (int) kPictureAttribute_MAX; 292 for (int j = 0; j < kPictureAttribute_MAX; 293 (i = (i+1) % kPictureAttribute_MAX), j++) 294 { 295 if (toMask((PictureAttribute) i) & supported) 296 return (PictureAttribute) i; 297 } 298 return kPictureAttribute_None; 299 } 300 215 301 #endif // _VIDEOOUT_TYPES_H_ -
libs/libmythtv/videooutbase.cpp
243 243 db_pip_location(kPIPTopLeft), db_pip_size(26), 244 244 db_aspectoverride(kAspect_Off), db_adjustfill(kAdjustFill_Off), 245 245 db_deint_filtername(QString::null), 246 db_use_picture_controls(false), 246 247 db_vdisp_profile(new VideoDisplayProfile()), 247 248 248 249 // Manual Zoom … … 283 284 // Various state variables 284 285 embedding(false), needrepaint(false), 285 286 allowpreviewepg(true), errored(false), 286 framesPlayed(0), db_scaling_allowed(true) 287 framesPlayed(0), db_scaling_allowed(true), 288 supported_attributes(kPictureAttributeSupported_None) 287 289 { 288 290 db_display_dim = QSize(gContext->GetNumSetting("DisplaySizeWidth", 0), 289 291 gContext->GetNumSetting("DisplaySizeHeight", 0)); … … 309 311 gContext->GetNumSetting("AspectOverride", 0); 310 312 db_adjustfill = (AdjustFillMode) 311 313 gContext->GetNumSetting("AdjustFill", 0); 314 315 db_use_picture_controls = 316 gContext->GetNumSetting("UseOutputPictureControls", 0); 312 317 } 313 318 314 319 /** -
libs/libmythtv/videoout_xv.h
87 87 void DrawUnusedRects(bool sync = true); 88 88 void UpdatePauseFrame(void); 89 89 int SetPictureAttribute(PictureAttribute attribute, int newValue); 90 void InitPictureAttributes(void); 90 91 91 92 int GetRefreshRate(void); 92 93 … … 201 202 VOSType video_output_subtype; 202 203 DisplayRes *display_res; 203 204 QMutex global_lock; 204 bool use_picture_controls;205 205 bool use_i420_hack_for_broken_driver; 206 206 207 207 // Basic X11 info … … 256 256 int xv_chroma; 257 257 buffer_map_t xv_buffers; 258 258 bool xv_need_bobdeint_repaint; 259 QMap<PictureAttribute,int> xv_attribute_min; 260 QMap<PictureAttribute,int> xv_attribute_max; 259 261 260 262 // OpenGL drawing info 261 263 QMutex gl_context_lock; -
libs/libmythtv/videoout_xv.cpp
101 101 : VideoOutput(), 102 102 myth_codec_id(codec_id), video_output_subtype(XVUnknown), 103 103 display_res(NULL), global_lock(true), 104 use_picture_controls(false),105 104 use_i420_hack_for_broken_driver(false), 106 105 107 106 XJ_root(0), XJ_win(0), XJ_curwin(0), XJ_gc(0), XJ_screen(NULL), … … 548 547 .arg(display_aspect)); 549 548 } 550 549 550 class XvAttributes 551 { 552 public: 553 XvAttributes() : 554 description(QString::null), xv_flags(0), feature_flags(0) {} 555 XvAttributes(const QString &a, uint b, uint c) : 556 description(QDeepCopy<QString>(a)), xv_flags(b), feature_flags(c) {} 557 558 public: 559 QString description; 560 uint xv_flags; 561 uint feature_flags; 562 563 static const uint kFeatureNone = 0x0000; 564 static const uint kFeatureXvMC = 0x0001; 565 static const uint kFeatureVLD = 0x0002; 566 static const uint kFeatureIDCT = 0x0004; 567 static const uint kFeatureChromakey = 0x0008; 568 static const uint kFeaturePicCtrl = 0x0010; 569 }; 570 551 571 /** 552 572 * Internal function used to grab a XVideo port with the desired properties. 553 573 * … … 560 580 XvMCSurfaceInfo* xvmc_surf_info, 561 581 QString *adaptor_name) 562 582 { 563 uint neededFlags[] = { XvInputMask,564 XvInputMask,565 XvInputMask,566 XvInputMask | XvImageMask };567 bool useXVMC[] = { true, true, true, false };568 bool useVLD[] = { true, false, false, false };569 bool useIDCT[] = { false, true, false, false };570 571 583 // avoid compiler warnings 572 (void)width; (void)height; (void)xvmc_chroma; (void)xvmc_surf_info; 573 (void)useVLD[0]; (void)useIDCT[0]; 584 (void)xvmc_chroma; (void)xvmc_surf_info; 574 585 575 QString msg[] =576 {577 "XvMC surface found with VLD support on port %1",578 "XvMC surface found with IDCT support on port %1",579 "XvMC surface found with MC support on port %1",580 "XVideo surface found on port %1"581 };582 583 586 if (adaptor_name) 584 587 *adaptor_name = QString::null; 585 588 589 // figure out what basic kind of surface we want.. 590 int stream_type = 0; 591 bool need_mc = false, need_idct = false; 592 bool need_vld = false, need_xv = false; 593 switch (mcodecid) 594 { 595 case kCodec_MPEG1_XVMC: stream_type = 1; need_mc = true; break; 596 case kCodec_MPEG2_XVMC: stream_type = 2; need_mc = true; break; 597 case kCodec_H263_XVMC: stream_type = 3; need_mc = true; break; 598 case kCodec_MPEG4_XVMC: stream_type = 4; need_mc = true; break; 599 600 case kCodec_MPEG1_IDCT: stream_type = 1; need_idct = true; break; 601 case kCodec_MPEG2_IDCT: stream_type = 2; need_idct = true; break; 602 case kCodec_H263_IDCT: stream_type = 3; need_idct = true; break; 603 case kCodec_MPEG4_IDCT: stream_type = 4; need_idct = true; break; 604 605 case kCodec_MPEG1_VLD: stream_type = 1; need_vld = true; break; 606 case kCodec_MPEG2_VLD: stream_type = 2; need_vld = true; break; 607 case kCodec_H263_VLD: stream_type = 3; need_vld = true; break; 608 case kCodec_MPEG4_VLD: stream_type = 4; need_vld = true; break; 609 610 default: 611 need_xv = true; 612 break; 613 } 614 615 // create list of requirements to check in order.. 616 vector<XvAttributes> req; 617 if (need_vld) 618 { 619 req.push_back(XvAttributes( 620 "XvMC surface found with VLD support on port %1", 621 XvInputMask, XvAttributes::kFeatureXvMC | 622 XvAttributes::kFeatureVLD)); 623 } 624 625 if (need_idct) 626 { 627 req.push_back(XvAttributes( 628 "XvMC surface found with IDCT support on port %1", 629 XvInputMask, XvAttributes::kFeatureXvMC | 630 XvAttributes::kFeatureIDCT)); 631 } 632 633 if (need_mc) 634 { 635 req.push_back(XvAttributes( 636 "XvMC surface found with MC support on port %1", 637 XvInputMask, XvAttributes::kFeatureXvMC)); 638 } 639 640 if (need_xv) 641 { 642 req.push_back(XvAttributes( 643 "XVideo surface found on port %1", 644 XvInputMask | XvImageMask, 645 XvAttributes::kFeatureNone)); 646 } 647 648 // try to get an adapter with picture attributes 649 if (true) 650 { 651 uint end = req.size(); 652 for (uint i = 0; i < end; i++) 653 { 654 req.push_back(req[i]); 655 req[i].feature_flags |= XvAttributes::kFeaturePicCtrl; 656 } 657 } 658 659 // figure out if we want chromakeying.. 660 VideoDisplayProfile vdp; 661 vdp.SetInput(QSize(width, height)); 662 bool check_for_colorkey = (vdp.GetOSDRenderer() == "chromakey"); 663 664 // if we want colorkey capability try to get an adapter with them 665 if (check_for_colorkey) 666 { 667 uint end = req.size(); 668 for (uint i = 0; i < end; i++) 669 { 670 req.push_back(req[i]); 671 req[i].feature_flags |= XvAttributes::kFeatureChromakey; 672 } 673 } 674 586 675 // get the list of Xv ports 587 676 XvAdaptorInfo *ai = NULL; 588 677 uint p_num_adaptors = 0; … … 596 685 return -1; 597 686 } 598 687 599 // find an Xv port600 int port = -1, stream_type = 0;601 uint begin = 0, end = 4;602 switch (mcodecid)603 {604 case kCodec_MPEG1_XVMC: (stream_type = 1),(begin = 2),(end = 3); break;605 case kCodec_MPEG2_XVMC: (stream_type = 2),(begin = 2),(end = 3); break;606 case kCodec_H263_XVMC: (stream_type = 3),(begin = 2),(end = 3); break;607 case kCodec_MPEG4_XVMC: (stream_type = 4),(begin = 2),(end = 3); break;608 609 case kCodec_MPEG1_IDCT: (stream_type = 1),(begin = 1),(end = 2); break;610 case kCodec_MPEG2_IDCT: (stream_type = 2),(begin = 1),(end = 2); break;611 case kCodec_H263_IDCT: (stream_type = 3),(begin = 1),(end = 2); break;612 case kCodec_MPEG4_IDCT: (stream_type = 4),(begin = 1),(end = 2); break;613 614 case kCodec_MPEG1_VLD: (stream_type = 1),(begin = 0),(end = 1); break;615 case kCodec_MPEG2_VLD: (stream_type = 2),(begin = 0),(end = 1); break;616 case kCodec_H263_VLD: (stream_type = 3),(begin = 0),(end = 1); break;617 case kCodec_MPEG4_VLD: (stream_type = 4),(begin = 0),(end = 1); break;618 619 default:620 begin = 3; end = 4;621 break;622 }623 624 688 QString lastAdaptorName = QString::null; 689 int port = -1; 625 690 626 VideoDisplayProfile vdp; 627 vdp.SetInput(QSize(width, height)); 628 QString osdtype = vdp.GetOSDRenderer(); 629 bool check_for_colorkey = (osdtype == "chromakey"); 630 for (uint j = begin; j < end; ++j) 691 // find an Xv port 692 for (uint j = 0; j < req.size(); ++j) 631 693 { 632 VERBOSE(VB_PLAYBACK, LOC + QString("@ j=%1 Looking for flag[s]: %2") 633 .arg(j).arg(xvflags2str(neededFlags[j]))); 694 VERBOSE(VB_PLAYBACK, LOC + QString("@ j=%1 Looking for flag[s]: %2 %3") 695 .arg(j).arg(xvflags2str(req[j].xv_flags)) 696 .arg(req[j].feature_flags,0,16)); 634 697 635 698 for (int i = 0; i < (int)p_num_adaptors && (port == -1); ++i) 636 699 { … … 639 702 QString("Adaptor#%1: %2 has flag[s]: %3") 640 703 .arg(i).arg(lastAdaptorName).arg(xvflags2str(ai[i].type))); 641 704 642 if ((ai[i].type & neededFlags[j]) != neededFlags[j]) 705 if ((ai[i].type & req[j].xv_flags) != req[j].xv_flags) 706 { 707 VERBOSE(VB_PLAYBACK, LOC + "Missing XVideo flags, rejecting."); 643 708 continue; 709 } 710 else 711 VERBOSE(VB_PLAYBACK, LOC + "Has XVideo flags..."); 644 712 645 713 const XvPortID firstPort = ai[i].base_id; 646 714 const XvPortID lastPort = ai[i].base_id + ai[i].num_ports - 1; 647 715 XvPortID p = 0; 648 716 649 if (check_for_colorkey) 717 if ((req[j].feature_flags & XvAttributes::kFeaturePicCtrl) && 718 (!xv_is_attrib_supported(disp, firstPort, "XV_BRIGHTNESS"))) 650 719 { 651 int colorkey = 0; 652 X11S(colorkey = colorkey_supported(disp, firstPort)); 653 if (!colorkey) 654 { 655 if (i == ((int)p_num_adaptors - 1)) 656 { 657 VERBOSE(VB_PLAYBACK, LOC + 658 "Failed to find XV_COLORKEY support. " 659 "Disabling XV_COLORKEY check"); 660 check_for_colorkey = false; 661 i = -1; 662 } 663 continue; 664 } 720 VERBOSE(VB_PLAYBACK, LOC + 721 "Missing XV_BRIGHTNESS, rejecting."); 722 continue; 665 723 } 724 else if (req[j].feature_flags & XvAttributes::kFeaturePicCtrl) 725 VERBOSE(VB_PLAYBACK, LOC + "Has XV_BRIGHTNESS..."); 666 726 667 if (useXVMC[j]) 727 if ((req[j].feature_flags & XvAttributes::kFeatureChromakey) && 728 (!xv_is_attrib_supported(disp, firstPort, "XV_COLORKEY"))) 668 729 { 730 VERBOSE(VB_PLAYBACK, LOC + 731 "Missing XV_COLORKEY, rejecting."); 732 continue; 733 } 734 else if (req[j].feature_flags & XvAttributes::kFeatureChromakey) 735 VERBOSE(VB_PLAYBACK, LOC + "Has XV_COLORKEY..."); 736 737 VERBOSE(VB_PLAYBACK, LOC + "Here..."); 738 739 if (req[j].feature_flags & XvAttributes::kFeatureXvMC) 740 { 669 741 #ifdef USING_XVMC 670 742 int surfNum; 671 XvMCSurfaceTypes::find(width, height, xvmc_chroma, 672 useVLD[j], useIDCT[j], stream_type, 673 0, 0, 674 disp, firstPort, lastPort, 675 p, surfNum); 743 XvMCSurfaceTypes::find( 744 width, height, xvmc_chroma, 745 req[j].feature_flags & XvAttributes::kFeatureVLD, 746 req[j].feature_flags & XvAttributes::kFeatureIDCT, 747 stream_type, 748 0, 0, 749 disp, firstPort, lastPort, 750 p, surfNum); 751 676 752 if (surfNum<0) 677 753 continue; 678 754 … … 718 794 } 719 795 if (port != -1) 720 796 { 721 VERBOSE(VB_PLAYBACK, LOC + msg[j].arg(port));797 VERBOSE(VB_PLAYBACK, LOC + req[j].description.arg(port)); 722 798 break; 723 799 } 724 800 } … … 866 942 gl_context->Show(); 867 943 gl_context->MakeCurrent(true); 868 944 gl_videochain = new OpenGLVideo(); 869 ok = gl_videochain->Init(gl_context, use_picture_controls,945 ok = gl_videochain->Init(gl_context, db_use_picture_controls, 870 946 true, video_dim, 871 947 display_visible_rect, 872 948 display_video_rect, video_rect, true); … … 1455 1531 db_vdisp_profile->SetVideoRenderer(renderer); 1456 1532 } 1457 1533 1458 // This needs to be here because OpenGL needs it in InitVideoBuffers()..1459 use_picture_controls =1460 gContext->GetNumSetting("UseOutputPictureControls", 0);1461 1462 1534 // Create video buffers 1463 1535 bool use_xv = (renderer.left(2) == "xv"); 1464 1536 bool use_shm = (renderer == "xshm"); … … 1489 1561 XV_INIT_FATAL_ERROR_TEST(!ok, "Failed to get any video output (nCK)"); 1490 1562 } 1491 1563 1492 // The OpenGL video output method always allows picture controls. 1493 // The XVideo output methods sometimes allow the picture to 1494 // be adjusted, if the chroma keying color can be discovered. 1495 use_picture_controls &= 1496 (VideoOutputSubType() >= XVideo && xv_colorkey) || 1497 (VideoOutputSubType() == OpenGL); 1498 1499 if (use_picture_controls) 1564 // Initialize the picture controls if we need to.. 1565 if (db_use_picture_controls) 1500 1566 InitPictureAttributes(); 1501 1567 1502 1568 return true; … … 1563 1629 */ 1564 1630 void VideoOutputXv::InitColorKey(bool turnoffautopaint) 1565 1631 { 1566 int ret = Success, xv_val=0; 1632 static const char *attr_autopaint = "XV_AUTOPAINT_COLORKEY"; 1633 int xv_val=0; 1634 1635 // handle autopaint.. Normally we try to disable it so that bob-deint 1636 // doesn't actually bob up the top and bottom borders up and down... 1567 1637 xv_draw_colorkey = true; 1568 xv_colorkey = 0; // set to invalid value as a sentinel 1569 1570 Atom xv_atom; 1571 XvAttribute *attributes; 1572 int attrib_count; 1573 1574 X11S(attributes = XvQueryPortAttributes(XJ_disp, xv_port, &attrib_count)); 1575 for (int i = (attributes) ? 0 : attrib_count; i < attrib_count; i++) 1638 if (xv_is_attrib_supported(XJ_disp, xv_port, attr_autopaint, &xv_val)) 1576 1639 { 1577 if ( !strcmp(attributes[i].name, "XV_AUTOPAINT_COLORKEY"))1640 if (turnoffautopaint && xv_val) 1578 1641 { 1579 X11S(xv_atom = XInternAtom(XJ_disp, "XV_AUTOPAINT_COLORKEY", False)); 1580 if (xv_atom == None) 1581 continue; 1642 xv_set_attrib(XJ_disp, xv_port, attr_autopaint, 0); 1643 if (!xv_get_attrib(XJ_disp, xv_port, attr_autopaint, xv_val) || 1644 xv_val) 1645 { 1646 VERBOSE(VB_IMPORTANT, "Failed to disable autopaint"); 1647 xv_draw_colorkey = false; 1648 } 1649 } 1650 else if (!turnoffautopaint && !xv_val) 1651 { 1652 xv_set_attrib(XJ_disp, xv_port, attr_autopaint, 1); 1653 if (!xv_get_attrib(XJ_disp, xv_port, attr_autopaint, xv_val) || 1654 !xv_val) 1655 { 1656 VERBOSE(VB_IMPORTANT, "Failed to enable autopaint"); 1657 } 1658 } 1659 else if (!turnoffautopaint && xv_val) 1660 { 1661 xv_draw_colorkey = false; 1662 } 1663 } 1582 1664 1583 X11L; 1584 if (turnoffautopaint) 1585 ret = XvSetPortAttribute(XJ_disp, xv_port, xv_atom, 0); 1586 else 1587 ret = XvSetPortAttribute(XJ_disp, xv_port, xv_atom, 1); 1665 // Check that we have a colorkey attribute and make sure it is not 1666 // the same color as the MythTV letterboxing (currently Black). 1667 // This avoids avoid bob-deint actually bobbing the borders of 1668 // the video up and down.. 1669 int letterbox_color = 0; 1670 static const char *attr_chroma = "XV_COLORKEY"; 1671 if (!xv_is_attrib_supported(XJ_disp, xv_port, attr_chroma, &xv_colorkey)) 1672 { 1673 // set to MythTV letterbox color as a sentinel 1674 xv_colorkey = letterbox_color; 1675 } 1676 else if (xv_colorkey == letterbox_color) 1677 { 1678 // if it is a valid attribute and set to the letterbox color, change it 1679 xv_set_attrib(XJ_disp, xv_port, attr_chroma, 1); 1588 1680 1589 ret = XvGetPortAttribute(XJ_disp, xv_port, xv_atom, &xv_val); 1590 // turn of colorkey drawing if autopaint is on 1591 if (Success == ret && xv_val) 1592 xv_draw_colorkey = false; 1593 X11U; 1681 if (xv_get_attrib(XJ_disp, xv_port, attr_chroma, xv_val) && 1682 xv_val != letterbox_color) 1683 { 1684 xv_colorkey = xv_val; 1594 1685 } 1595 1686 } 1596 if (attributes)1597 X11S(XFree(attributes));1598 1687 1599 if (!xv_draw_colorkey) 1600 return; 1601 1602 QString msg = LOC + "Chromakeying not possible with this XVideo port."; 1603 X11S(xv_colorkey = colorkey_supported(XJ_disp, xv_port)); 1604 if (!xv_colorkey) 1688 if (xv_colorkey == letterbox_color) 1605 1689 { 1606 VERBOSE(VB_PLAYBACK, msg);1607 return;1690 VERBOSE(VB_PLAYBACK, LOC + 1691 "Chromakeying not possible with this XVideo port."); 1608 1692 } 1609 1693 } 1610 1694 … … 3020 3104 { 3021 3105 VERBOSE(VB_PLAYBACK, LOC + "Initialise PiP."); 3022 3106 gl_pipchain = new OpenGLVideo(); 3023 bool success = gl_pipchain->Init(gl_context, use_picture_controls,3107 bool success = gl_pipchain->Init(gl_context, db_use_picture_controls, 3024 3108 true, QSize(pipVideoWidth, pipVideoHeight), 3025 3109 position, position, 3026 3110 QRect(0, 0, pipVideoWidth, pipVideoHeight), false); … … 3040 3124 VERBOSE(VB_PLAYBACK, LOC + "Re-initialise PiP."); 3041 3125 3042 3126 bool success = gl_pipchain->ReInit( 3043 gl_context, use_picture_controls,3127 gl_context, db_use_picture_controls, 3044 3128 true, QSize(pipVideoWidth, pipVideoHeight), 3045 3129 position, position, 3046 3130 QRect(0, 0, pipVideoWidth, pipVideoHeight), false); … … 3693 3777 int VideoOutputXv::SetPictureAttribute( 3694 3778 PictureAttribute attribute, int newValue) 3695 3779 { 3696 if (! use_picture_controls)3780 if (!supported_attributes) 3697 3781 return -1; 3698 3782 3699 3783 if (VideoOutputSubType() == OpenGL) … … 3705 3789 return newValue; 3706 3790 } 3707 3791 3708 QString attrName = QString::null;3709 int valAdj =0;3792 QString attrName = toXVString(attribute); 3793 int valAdj = (kPictureAttribute_Hue == attribute) ? xv_hue_base : 0; 3710 3794 3711 if (kPictureAttribute_Brightness == attribute)3712 attrName = "XV_BRIGHTNESS";3713 else if (kPictureAttribute_Contrast == attribute)3714 attrName = "XV_CONTRAST";3715 else if (kPictureAttribute_Colour == attribute)3716 attrName = "XV_SATURATION";3717 else if (kPictureAttribute_Hue == attribute)3718 {3719 attrName = "XV_HUE";3720 valAdj = xv_hue_base;3721 }3722 3723 3795 if (attrName.isEmpty()) 3724 3796 return -1; 3725 3797 3798 if (0 == ((1<<((int)attribute)) & supported_attributes)) 3799 return -1; 3800 3726 3801 newValue = min(max(newValue, 0), 100); 3727 3802 3728 Atom attributeAtom = None; 3729 X11S(attributeAtom = XInternAtom(XJ_disp, attrName.ascii(), False)); 3730 if (attributeAtom == None) 3731 return -1; 3803 int port_min = xv_attribute_min[attribute]; 3804 int port_max = xv_attribute_max[attribute]; 3805 int range = port_max - port_min; 3806 3807 int tmpval2 = (newValue + valAdj) % 100; 3808 int tmpval3 = (int) roundf(range * 0.01f * tmpval2); 3809 int value = min(tmpval3 + port_min, port_max); 3732 3810 3733 XvAttribute *attributes = NULL; 3734 int howmany; 3735 X11S(attributes = XvQueryPortAttributes(XJ_disp, xv_port, &howmany)); 3736 if (!attributes) 3737 return -1; 3811 xv_set_attrib(XJ_disp, xv_port, attrName.ascii(), value); 3738 3812 3739 bool value_set = false; 3740 for (int i = 0; i < howmany; i++) 3813 #ifdef USING_XVMC 3814 // Needed for VIA XvMC to commit change immediately. 3815 if (video_output_subtype > XVideo) 3741 3816 { 3742 if (attrName != attributes[i].name) 3743 continue; 3817 Atom xv_atom; 3818 X11S(xv_atom = XInternAtom(XJ_disp, attrName.ascii(), False)); 3819 if (xv_atom != None) 3820 X11S(XvMCSetAttribute(XJ_disp, xvmc_ctx, xv_atom, value)); 3821 } 3822 #endif 3744 3823 3745 int port_min = attributes[i].min_value;3746 int port_max = attributes[i].max_value;3747 int range = port_max - port_min; 3824 SetPictureAttributeDBValue(attribute, newValue); 3825 return newValue; 3826 } 3748 3827 3749 int tmpval2 = (newValue + valAdj) % 100; 3750 int tmpval3 = (int) roundf(range * 0.01f * tmpval2); 3751 int value = min(tmpval3 + port_min, port_max); 3752 value_set = true; 3828 void VideoOutputXv::InitPictureAttributes(void) 3829 { 3830 supported_attributes = kPictureAttributeSupported_None; 3753 3831 3754 X11L; 3755 XvSetPortAttribute(XJ_disp, xv_port, attributeAtom, value); 3756 #ifdef USING_XVMC 3757 // Needed for VIA XvMC to commit change immediately. 3758 if (video_output_subtype > XVideo) 3759 XvMCSetAttribute(XJ_disp, xvmc_ctx, attributeAtom, value); 3760 #endif 3761 X11U; 3762 break; 3832 if (VideoOutputSubType() == OpenGL) 3833 { 3834 supported_attributes = gl_videochain->GetSupportedPictureAttributes(); 3763 3835 } 3836 else if (VideoOutputSubType() >= XVideo) 3837 { 3838 int val, min_val, max_val; 3839 for (uint i = 0; i < kPictureAttribute_MAX; i++) 3840 { 3841 QString attrName = toXVString((PictureAttribute)i); 3842 if (attrName.isEmpty()) 3843 continue; 3764 3844 3765 X11S(XFree(attributes)); 3845 if (xv_is_attrib_supported(XJ_disp, xv_port, attrName.ascii(), 3846 &val, &min_val, &max_val)) 3847 { 3848 supported_attributes = (PictureAttributeSupported) 3849 (supported_attributes | toMask((PictureAttribute)i)); 3850 xv_attribute_min[(PictureAttribute)i] = min_val; 3851 xv_attribute_max[(PictureAttribute)i] = max_val; 3852 } 3853 } 3854 } 3855 else 3856 { 3857 return; 3858 } 3766 3859 3767 if (!value_set)3768 return -1;3860 VERBOSE(VB_PLAYBACK, LOC + QString("PictureAttributes: 0x%1") 3861 .arg(toString(supported_attributes))); 3769 3862 3770 SetPictureAttributeDBValue(attribute, newValue); 3771 return newValue; 3863 VideoOutput::InitPictureAttributes(); 3772 3864 } 3773 3865 3774 3866 void VideoOutputXv::CheckFrameStates(void) -
libs/libmythtv/videooutbase.h
106 106 /// \brief Tells video output that a full repaint is needed. 107 107 void ExposeEvent(void) { needrepaint = true; } 108 108 109 PictureAttributeSupported GetSupportedPictureAttributes(void) const 110 { return supported_attributes; } 109 111 int ChangePictureAttribute(PictureAttribute, bool direction); 110 112 virtual int SetPictureAttribute(PictureAttribute, int newValue); 111 113 int GetPictureAttribute(PictureAttribute) const; 112 v oidInitPictureAttributes(void);114 virtual void InitPictureAttributes(void); 113 115 114 116 bool AllowPreviewEPG(void) { return allowpreviewepg; } 115 117 … … 243 245 float db_scale_vert; ///< Vertical Overscan/Underscan percentage 244 246 PIPLocation db_pip_location; 245 247 int db_pip_size; ///< percentage of full window to use for PiP 246 247 248 typedef QMap<PictureAttribute,int> PictureSettingMap; 248 249 PictureSettingMap db_pict_attr; ///< Picture settings 249 250 AspectOverrideMode db_aspectoverride; 250 251 AdjustFillMode db_adjustfill; 251 252 QString db_deint_filtername; 253 bool db_use_picture_controls; 252 254 253 255 VideoDisplayProfile *db_vdisp_profile; 254 256 … … 315 317 bool errored; 316 318 long long framesPlayed; 317 319 bool db_scaling_allowed; ///< disable this to prevent overscan/underscan 320 PictureAttributeSupported supported_attributes; 318 321 }; 319 322 320 323 #endif -
programs/mythfrontend/globalsettings.cpp
1783 1783 return gc; 1784 1784 } 1785 1785 1786 #ifdef USING_XV1787 1786 static HostCheckBox *UsePicControls() 1788 1787 { 1789 1788 HostCheckBox *gc = new HostCheckBox("UseOutputPictureControls"); 1790 gc->setLabel(QObject::tr(" Use Xvpicture controls"));1789 gc->setLabel(QObject::tr("Enable picture controls")); 1791 1790 gc->setValue(false); 1792 gc->setHelpText(QObject::tr("If enabled, Xv picture controls (brightness, " 1793 "contrast, etc.) are used during playback. These are " 1794 "independent of the Video4Linux controls used for " 1795 "recording. The Xv controls may not work properly on " 1796 "some systems.")); 1791 gc->setHelpText( 1792 QObject::tr( 1793 "If enabled, MythTV attempts to initialize picture controls " 1794 "(brightness, contrast, etc.) that are applied during playback.")); 1797 1795 return gc; 1798 1796 } 1799 #endif1800 1797 1801 1798 static HostCheckBox *AudioNagSetting() 1802 1799 { … … 4356 4353 #ifdef USING_OPENGL_VSYNC 4357 4354 general1->addChild(UseOpenGLVSync()); 4358 4355 #endif // USING_OPENGL_VSYNC 4359 #ifdef USING_XV4360 4356 general1->addChild(UsePicControls()); 4361 #endif // USING_XV4362 4357 addChild(general1); 4363 4358 4364 4359 VerticalConfigurationGroup* general2 =