mirror of
				https://projects.vdr-developer.org/git/vdr-plugin-softhddevice.git
				synced 2023-10-10 17:16:51 +00:00 
			
		
		
		
	Support configuration and set of video background.
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
User johns
 | 
			
		||||
Date:
 | 
			
		||||
 | 
			
		||||
    Support configuration and set of video background.
 | 
			
		||||
    Survive lost X11 display.
 | 
			
		||||
    Fix bug: 100% cpu use with plugins like mp3.
 | 
			
		||||
    Wakeup display thread on channel switch, osd can now be shown without
 | 
			
		||||
 
 | 
			
		||||
@@ -66,6 +66,7 @@ static const char *const Resolution[RESOLUTIONS] = {
 | 
			
		||||
static char ConfigMakePrimary;		///< config primary wanted
 | 
			
		||||
static char ConfigHideMainMenuEntry;	///< config hide main menu entry
 | 
			
		||||
 | 
			
		||||
static uint32_t ConfigVideoBackground;	///< config video background color
 | 
			
		||||
static int ConfigVideoSkipLines;	///< config skip lines top/bottom
 | 
			
		||||
static int ConfigVideoStudioLevels;	///< config use studio levels
 | 
			
		||||
static int ConfigVideo60HzMode;		///< config use 60Hz display mode
 | 
			
		||||
@@ -411,6 +412,8 @@ class cMenuSetupSoft:public cMenuSetupPage
 | 
			
		||||
    /// @{
 | 
			
		||||
    int MakePrimary;
 | 
			
		||||
    int HideMainMenuEntry;
 | 
			
		||||
    uint32_t Background;
 | 
			
		||||
    uint32_t BackgroundAlpha;
 | 
			
		||||
    int SkipLines;
 | 
			
		||||
    int StudioLevels;
 | 
			
		||||
    int Scaling[RESOLUTIONS];
 | 
			
		||||
@@ -482,6 +485,13 @@ cMenuSetupSoft::cMenuSetupSoft(void)
 | 
			
		||||
    //
 | 
			
		||||
    Add(SeparatorItem(tr("Video")));
 | 
			
		||||
 | 
			
		||||
    // no unsigned int menu item supported, split background color/alpha
 | 
			
		||||
    Background = ConfigVideoBackground >> 8;
 | 
			
		||||
    BackgroundAlpha = ConfigVideoBackground & 0xFF;
 | 
			
		||||
    Add(new cMenuEditIntItem(tr("video background color (RGB)"),
 | 
			
		||||
	    (int *)&Background, 0, 0x00FFFFFF));
 | 
			
		||||
    Add(new cMenuEditIntItem(tr("video background color (Alpha)"),
 | 
			
		||||
	    (int *)&BackgroundAlpha, 0, 0xFF));
 | 
			
		||||
    SkipLines = ConfigVideoSkipLines;
 | 
			
		||||
    Add(new cMenuEditIntItem(tr("Skip lines top+bot (pixel)"), &SkipLines, 0,
 | 
			
		||||
	    64));
 | 
			
		||||
@@ -504,10 +514,10 @@ cMenuSetupSoft::cMenuSetupSoft(void)
 | 
			
		||||
		&InverseTelecine[i], trVDR("no"), trVDR("yes")));
 | 
			
		||||
	Denoise[i] = ConfigVideoDenoise[i];
 | 
			
		||||
	Add(new cMenuEditIntItem(tr("Denoise (0..1000) (vdpau)"), &Denoise[i],
 | 
			
		||||
		0, 1000));
 | 
			
		||||
		0, 1000, tr("off"), tr("max")));
 | 
			
		||||
	Sharpen[i] = ConfigVideoSharpen[i];
 | 
			
		||||
	Add(new cMenuEditIntItem(tr("Sharpen (-1000..1000) (vdpau)"),
 | 
			
		||||
		&Sharpen[i], -1000, 1000));
 | 
			
		||||
		&Sharpen[i], -1000, 1000, tr("blur max"), tr("sharpen max")));
 | 
			
		||||
    }
 | 
			
		||||
    //
 | 
			
		||||
    //	audio
 | 
			
		||||
@@ -528,7 +538,7 @@ cMenuSetupSoft::cMenuSetupSoft(void)
 | 
			
		||||
    Add(SeparatorItem(tr("Auto-crop")));
 | 
			
		||||
    AutoCropInterval = ConfigAutoCropInterval;
 | 
			
		||||
    Add(new cMenuEditIntItem(tr("autocrop interval (frames)"),
 | 
			
		||||
	    &AutoCropInterval, 0, 200));
 | 
			
		||||
	    &AutoCropInterval, 0, 200, tr("off")));
 | 
			
		||||
    AutoCropDelay = ConfigAutoCropDelay;
 | 
			
		||||
    Add(new cMenuEditIntItem(tr("autocrop delay (n * interval)"),
 | 
			
		||||
	    &AutoCropDelay, 0, 200));
 | 
			
		||||
@@ -558,6 +568,9 @@ void cMenuSetupSoft::Store(void)
 | 
			
		||||
    SetupStore("HideMainMenuEntry", ConfigHideMainMenuEntry =
 | 
			
		||||
	HideMainMenuEntry);
 | 
			
		||||
 | 
			
		||||
    ConfigVideoBackground = Background << 8 | (BackgroundAlpha & 0xFF);
 | 
			
		||||
    SetupStore("Background", ConfigVideoBackground);
 | 
			
		||||
    VideoSetBackground(ConfigVideoBackground);
 | 
			
		||||
    SetupStore("SkipLines", ConfigVideoSkipLines = SkipLines);
 | 
			
		||||
    VideoSetSkipLines(ConfigVideoSkipLines);
 | 
			
		||||
    SetupStore("StudioLevels", ConfigVideoStudioLevels = StudioLevels);
 | 
			
		||||
@@ -1080,8 +1093,8 @@ bool cSoftHdDevice::Flush(int timeout_ms)
 | 
			
		||||
**	Sets the video display format to the given one (only useful if this
 | 
			
		||||
**	device has an MPEG decoder).
 | 
			
		||||
*/
 | 
			
		||||
void cSoftHdDevice::
 | 
			
		||||
SetVideoDisplayFormat(eVideoDisplayFormat video_display_format)
 | 
			
		||||
void cSoftHdDevice:: SetVideoDisplayFormat(eVideoDisplayFormat
 | 
			
		||||
    video_display_format)
 | 
			
		||||
{
 | 
			
		||||
    static int last = -1;
 | 
			
		||||
 | 
			
		||||
@@ -1487,6 +1500,10 @@ bool cPluginSoftHdDevice::SetupParse(const char *name, const char *value)
 | 
			
		||||
	ConfigHideMainMenuEntry = atoi(value);
 | 
			
		||||
	return true;
 | 
			
		||||
    }
 | 
			
		||||
    if (!strcasecmp(name, "Background")) {
 | 
			
		||||
	VideoSetBackground(ConfigVideoBackground = strtoul(value, NULL, 0));
 | 
			
		||||
	return true;
 | 
			
		||||
    }
 | 
			
		||||
    if (!strcasecmp(name, "SkipLines")) {
 | 
			
		||||
	VideoSetSkipLines(ConfigVideoSkipLines = atoi(value));
 | 
			
		||||
	return true;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										93
									
								
								video.c
									
									
									
									
									
								
							
							
						
						
									
										93
									
								
								video.c
									
									
									
									
									
								
							@@ -234,6 +234,7 @@ typedef struct _video_module_
 | 
			
		||||
    void (*const RenderFrame) (VideoHwDecoder *, const AVCodecContext *,
 | 
			
		||||
	const AVFrame *);
 | 
			
		||||
    uint8_t *(*const GrabOutput)(int *, int *, int *);
 | 
			
		||||
    void (*const SetBackground) (uint32_t);
 | 
			
		||||
    void (*const SetVideoMode) (void);
 | 
			
		||||
    void (*const ResetAutoCrop) (void);
 | 
			
		||||
 | 
			
		||||
@@ -293,6 +294,7 @@ static char VideoSurfaceModesChanged;	///< flag surface modes changed
 | 
			
		||||
    /// flag use transparent OSD.
 | 
			
		||||
static const char VideoTransparentOsd = 1;
 | 
			
		||||
 | 
			
		||||
static uint32_t VideoBackground;	///< video background color
 | 
			
		||||
static int VideoSkipLines;		///< skip video lines top/bottom
 | 
			
		||||
static char VideoStudioLevels;		///< flag use studio levels
 | 
			
		||||
 | 
			
		||||
@@ -2069,6 +2071,17 @@ static int VaapiInit(const char *display_name)
 | 
			
		||||
	attr.value ? _("direct mapped") : _("copied"));
 | 
			
		||||
    // FIXME: handle the cases: new liba: Don't use it.
 | 
			
		||||
 | 
			
		||||
    attr.type = VADisplayAttribBackgroundColor;
 | 
			
		||||
    attr.flags = VA_DISPLAY_ATTRIB_SETTABLE;
 | 
			
		||||
    if (vaGetDisplayAttributes(VaDisplay, &attr, 1) != VA_STATUS_SUCCESS) {
 | 
			
		||||
	Error(_("video/vaapi: Can't get background-color attribute\n"));
 | 
			
		||||
	attr.value = 1;
 | 
			
		||||
    }
 | 
			
		||||
    Info(_("video/vaapi: background-color is %s\n"),
 | 
			
		||||
	attr.value ? _("supported") : _("unsupported"));
 | 
			
		||||
 | 
			
		||||
    // FIXME: VaapiSetBackground(VideoBackground);
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
    //
 | 
			
		||||
    //	check the chroma format
 | 
			
		||||
@@ -4490,6 +4503,16 @@ static int64_t VaapiGetClock(const VaapiDecoder * decoder)
 | 
			
		||||
	2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
///	Set VA-API background color.
 | 
			
		||||
///
 | 
			
		||||
///	@param rgba	32 bit RGBA color.
 | 
			
		||||
///
 | 
			
		||||
static void VaapiSetBackground( __attribute__ ((unused)) uint32_t rgba)
 | 
			
		||||
{
 | 
			
		||||
    Error(_("video/vaapi: FIXME: SetBackground not supported\n"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
///	Set VA-API video mode.
 | 
			
		||||
///
 | 
			
		||||
@@ -4787,6 +4810,7 @@ static const VideoModule VaapiModule = {
 | 
			
		||||
    .RenderFrame = (void (*const) (VideoHwDecoder *,
 | 
			
		||||
	    const AVCodecContext *, const AVFrame *))VaapiSyncRenderFrame,
 | 
			
		||||
    .GrabOutput = NULL,
 | 
			
		||||
    .SetBackground = VaapiSetBackground,
 | 
			
		||||
    .SetVideoMode = VaapiSetVideoMode,
 | 
			
		||||
    .ResetAutoCrop = VaapiResetAutoCrop,
 | 
			
		||||
    .Thread = VaapiDisplayHandlerThread,
 | 
			
		||||
@@ -4886,8 +4910,9 @@ static VdpGetProcAddress *VdpauGetProcAddress;	///< entry point to use
 | 
			
		||||
    /// presentation queue target
 | 
			
		||||
static VdpPresentationQueueTarget VdpauQueueTarget;
 | 
			
		||||
static VdpPresentationQueue VdpauQueue;	///< presentation queue
 | 
			
		||||
static VdpColor VdpauBackgroundColor[1];	///< queue background color
 | 
			
		||||
static VdpColor VdpauQueueBackgroundColor[1];	///< queue background color
 | 
			
		||||
 | 
			
		||||
static int VdpauBackground;		///< background supported
 | 
			
		||||
static int VdpauHqScalingMax;		///< highest supported scaling level
 | 
			
		||||
static int VdpauTemporal;		///< temporal deinterlacer supported
 | 
			
		||||
static int VdpauTemporalSpatial;	///< temporal spatial deint. supported
 | 
			
		||||
@@ -5157,9 +5182,10 @@ static void VdpauMixerSetup(VdpauDecoder * decoder)
 | 
			
		||||
    VdpVideoMixerFeature features[15];
 | 
			
		||||
    VdpBool enables[15];
 | 
			
		||||
    int feature_n;
 | 
			
		||||
    VdpVideoMixerAttribute attributes[4];
 | 
			
		||||
    void const *attribute_value_ptrs[4];
 | 
			
		||||
    VdpVideoMixerAttribute attributes[5];
 | 
			
		||||
    void const *attribute_value_ptrs[5];
 | 
			
		||||
    int attribute_n;
 | 
			
		||||
    VdpColor background_color[1];
 | 
			
		||||
    uint8_t skip_chroma_value;
 | 
			
		||||
    float noise_reduction_level;
 | 
			
		||||
    float sharpness_level;
 | 
			
		||||
@@ -5235,7 +5261,20 @@ static void VdpauMixerSetup(VdpauDecoder * decoder)
 | 
			
		||||
       VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA
 | 
			
		||||
       VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    attribute_n = 0;
 | 
			
		||||
    // none video-area background color
 | 
			
		||||
    if (VdpauBackground) {
 | 
			
		||||
	background_color->red = (VideoBackground >> 24) / 255.0;
 | 
			
		||||
	background_color->green = ((VideoBackground >> 16) & 0xFF) / 255.0;
 | 
			
		||||
	background_color->blue = ((VideoBackground >> 8) & 0xFF) / 255.0;
 | 
			
		||||
	background_color->alpha = (VideoBackground & 0xFF) / 255.0;
 | 
			
		||||
	attributes[attribute_n] = VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR;
 | 
			
		||||
	attribute_value_ptrs[attribute_n++] = background_color;
 | 
			
		||||
	Debug(3, "video/vdpau: background color %f/%f/%f/%f\n",
 | 
			
		||||
	    background_color->red, background_color->green,
 | 
			
		||||
	    background_color->blue, background_color->alpha);
 | 
			
		||||
    }
 | 
			
		||||
    if (VdpauSkipChroma) {
 | 
			
		||||
	skip_chroma_value = VideoSkipChromaDeinterlace[decoder->Resolution];
 | 
			
		||||
	attributes[attribute_n]
 | 
			
		||||
@@ -5606,11 +5645,12 @@ static void VdpauInitOutputQueue(void)
 | 
			
		||||
	return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    VdpauBackgroundColor->red = 0.01;
 | 
			
		||||
    VdpauBackgroundColor->green = 0.02;
 | 
			
		||||
    VdpauBackgroundColor->blue = 0.03;
 | 
			
		||||
    VdpauBackgroundColor->alpha = 1.00;
 | 
			
		||||
    VdpauPresentationQueueSetBackgroundColor(VdpauQueue, VdpauBackgroundColor);
 | 
			
		||||
    VdpauQueueBackgroundColor->red = 0.01;
 | 
			
		||||
    VdpauQueueBackgroundColor->green = 0.02;
 | 
			
		||||
    VdpauQueueBackgroundColor->blue = 0.03;
 | 
			
		||||
    VdpauQueueBackgroundColor->alpha = 1.00;
 | 
			
		||||
    VdpauPresentationQueueSetBackgroundColor(VdpauQueue,
 | 
			
		||||
	VdpauQueueBackgroundColor);
 | 
			
		||||
 | 
			
		||||
    //
 | 
			
		||||
    //	Create display output surfaces
 | 
			
		||||
@@ -5906,6 +5946,16 @@ static int VdpauInit(const char *display_name)
 | 
			
		||||
    //
 | 
			
		||||
    //	Cache some features
 | 
			
		||||
    //
 | 
			
		||||
    status =
 | 
			
		||||
	VdpauVideoMixerQueryFeatureSupport(VdpauDevice,
 | 
			
		||||
	VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR, &flag);
 | 
			
		||||
    if (status != VDP_STATUS_OK) {
 | 
			
		||||
	Error(_("video/vdpau: can't query feature '%s': %s\n"),
 | 
			
		||||
	    "background-color", VdpauGetErrorString(status));
 | 
			
		||||
    } else {
 | 
			
		||||
	VdpauBackground = flag;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    status =
 | 
			
		||||
	VdpauVideoMixerQueryFeatureSupport(VdpauDevice,
 | 
			
		||||
	VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL, &flag);
 | 
			
		||||
@@ -5966,8 +6016,6 @@ static int VdpauInit(const char *display_name)
 | 
			
		||||
	VdpauSkipChroma = flag;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR
 | 
			
		||||
 | 
			
		||||
    if (VdpauHqScalingMax) {
 | 
			
		||||
	Info(_("video/vdpau: highest supported high quality scaling %d\n"),
 | 
			
		||||
	    VdpauHqScalingMax -
 | 
			
		||||
@@ -7562,7 +7610,16 @@ static int VdpauPreemptionRecover(void)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
///	Set VA-API video mode.
 | 
			
		||||
///	Set VDPAU background color.
 | 
			
		||||
///
 | 
			
		||||
///	@param rgba	32 bit RGBA color.
 | 
			
		||||
///
 | 
			
		||||
static void VdpauSetBackground( __attribute__ ((unused)) uint32_t rgba)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
///	Set VDPAU video mode.
 | 
			
		||||
///
 | 
			
		||||
static void VdpauSetVideoMode(void)
 | 
			
		||||
{
 | 
			
		||||
@@ -7902,6 +7959,7 @@ static const VideoModule VdpauModule = {
 | 
			
		||||
    .RenderFrame = (void (*const) (VideoHwDecoder *,
 | 
			
		||||
	    const AVCodecContext *, const AVFrame *))VdpauSyncRenderFrame,
 | 
			
		||||
    .GrabOutput = VdpauGrabOutputSurface,
 | 
			
		||||
    .SetBackground = VdpauSetBackground,
 | 
			
		||||
    .SetVideoMode = VdpauSetVideoMode,
 | 
			
		||||
    .ResetAutoCrop = VdpauResetAutoCrop,
 | 
			
		||||
    .Thread = VdpauDisplayHandlerThread,
 | 
			
		||||
@@ -9202,6 +9260,19 @@ void VideoSetStudioLevels(int onoff)
 | 
			
		||||
    VideoStudioLevels = onoff;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
///	Set background color.
 | 
			
		||||
///
 | 
			
		||||
///	@param rgba	32 bit RGBA color.
 | 
			
		||||
///
 | 
			
		||||
void VideoSetBackground(uint32_t rgba)
 | 
			
		||||
{
 | 
			
		||||
    VideoBackground = rgba;		// save for later start
 | 
			
		||||
    if (VideoUsedModule) {
 | 
			
		||||
	VideoUsedModule->SetBackground(rgba);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
///	Set audio delay.
 | 
			
		||||
///
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user