[vlc-commits] dxva2_deinterlace: fill the sample metadata from the source picture

Steve Lhomme git at videolan.org
Wed Sep 12 11:40:02 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Sep 12 11:39:29 2018 +0200| [195ecdd07db944098db6d59c1236c3a7eef9a874] | committer: Steve Lhomme

dxva2_deinterlace: fill the sample metadata from the source picture

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=195ecdd07db944098db6d59c1236c3a7eef9a874
---

 modules/hw/d3d9/dxva2_deinterlace.c | 58 +++++++++++++++++++++++++++++++++++--
 1 file changed, 56 insertions(+), 2 deletions(-)

diff --git a/modules/hw/d3d9/dxva2_deinterlace.c b/modules/hw/d3d9/dxva2_deinterlace.c
index 90b0440f31..76701d6a30 100644
--- a/modules/hw/d3d9/dxva2_deinterlace.c
+++ b/modules/hw/d3d9/dxva2_deinterlace.c
@@ -84,6 +84,56 @@ static void Flush(filter_t *filter)
     FlushDeinterlacing(&p_sys->context);
 }
 
+static void FillExtendedFormat( const video_format_t *p_fmt,
+                                DXVA2_ExtendedFormat *out )
+{
+    out->NominalRange = p_fmt->b_color_range_full ? DXVA2_NominalRange_0_255 : DXVA2_NominalRange_16_235;
+    switch (p_fmt->space)
+    {
+    case COLOR_SPACE_BT601:
+        out->VideoTransferMatrix = DXVA2_VideoTransferMatrix_BT601;
+        break;
+    case COLOR_SPACE_BT709:
+        out->VideoTransferMatrix = DXVA2_VideoTransferMatrix_BT709;
+        break;
+    default:
+        out->VideoTransferMatrix = DXVA2_VideoTransferMatrix_Unknown;
+        break;
+    }
+    out->VideoLighting = DXVA2_VideoLighting_Unknown;
+    switch (p_fmt->primaries)
+    {
+    case COLOR_PRIMARIES_BT709:
+        out->VideoPrimaries = DXVA2_VideoPrimaries_BT709;
+        break;
+    case COLOR_PRIMARIES_BT470_BG:
+        out->VideoPrimaries = DXVA2_VideoPrimaries_BT470_2_SysBG;
+        break;
+    case COLOR_PRIMARIES_SMTPE_170:
+        out->VideoPrimaries = DXVA2_VideoPrimaries_SMPTE170M;
+        break;
+    default:
+        out->VideoPrimaries = DXVA2_VideoPrimaries_Unknown;
+        break;
+    }
+    switch (p_fmt->transfer)
+    {
+    case TRANSFER_FUNC_BT709:
+        out->VideoTransferFunction = DXVA2_VideoTransFunc_709;
+        break;
+    case TRANSFER_FUNC_SMPTE_240:
+        out->VideoTransferFunction = DXVA2_VideoTransFunc_240M;
+        break;
+    case TRANSFER_FUNC_SRGB:
+        out->VideoTransferFunction = DXVA2_VideoTransFunc_sRGB;
+        break;
+    default:
+        out->VideoTransferFunction = DXVA2_VideoTransFunc_Unknown;
+        break;
+    }
+    out->VideoLighting = DXVA2_VideoLighting_dim;
+}
+
 static void FillSample( DXVA2_VideoSample *p_sample,
                         const struct deinterlace_ctx *p_context,
                         picture_t *p_pic,
@@ -97,6 +147,7 @@ static void FillSample( DXVA2_VideoSample *p_sample,
     p_sample->SampleFormat.SampleFormat = p_pic->b_top_field_first ?
                 DXVA2_SampleFieldInterleavedEvenFirst :
                 DXVA2_SampleFieldInterleavedOddFirst;
+    FillExtendedFormat(p_fmt, &p_sample->SampleFormat);
     p_sample->Start = 0;
     p_sample->End = GetFieldDuration(p_context, p_fmt, p_pic) * 10;
     p_sample->SampleData = DXVA2_SampleData_RFF_TFF_Present;
@@ -110,7 +161,8 @@ static void FillSample( DXVA2_VideoSample *p_sample,
 
 static void FillBlitParams( filter_sys_t *sys,
                             DXVA2_VideoProcessBltParams *params, const RECT *area,
-                            const DXVA2_VideoSample *samples, int order )
+                            const DXVA2_VideoSample *samples, int order,
+                            const video_format_t *fmt)
 {
     memset(params, 0, sizeof(*params));
     params->TargetFrame = (samples->End - samples->Start) * order / 2;
@@ -118,6 +170,7 @@ static void FillBlitParams( filter_sys_t *sys,
     params->DestData    = 0;
     params->Alpha       = DXVA2_Fixed32OpaqueAlpha();
     params->DestFormat.SampleFormat = DXVA2_SampleProgressiveFrame;
+    FillExtendedFormat(fmt, &params->DestFormat);
     params->BackgroundColor.Alpha = 0xFFFF;
     params->ConstrictionSize.cx = params->TargetRect.right;
     params->ConstrictionSize.cy = params->TargetRect.bottom;
@@ -184,7 +237,7 @@ static int RenderPic( filter_t *filter, picture_t *p_outpic, picture_t *src,
         }
     }
 
-    FillBlitParams( sys, &params, &area, samples, order );
+    FillBlitParams( sys, &params, &area, samples, order, &p_outpic->format );
 
     hr = IDirectXVideoProcessor_VideoProcessBlt( sys->processor,
                                                  sys->hw_surface,
@@ -366,6 +419,7 @@ int D3D9OpenDeinterlace(vlc_object_t *obj)
     }
     dsc.OutputFrameFreq = dsc.InputSampleFreq;
     dsc.SampleFormat.SampleFormat = DXVA2_SampleFieldInterleavedEvenFirst;
+    FillExtendedFormat(&filter->fmt_out.video, &dsc.SampleFormat);
 
     UINT count = 0;
     hr = IDirectXVideoProcessorService_GetVideoProcessorDeviceGuids( processor,



More information about the vlc-commits mailing list