public void UpdateBitrate(EncoderBitrate encoderBitrate)
 {
     lock (s_lock)
     {
         if (!_currentBitrate.Equals(encoderBitrate) && _handle != IntPtr.Zero)
         {
             _currentBitrate = encoderBitrate;
             EncoderContextQsvDx_UpdateBitrate(_handle, ref encoderBitrate);
         }
     }
 }
 public int Open(EncoderSetup setup)
 {
     lock (s_lock)
     {
         if (_handle != IntPtr.Zero)
         {
             EncoderConfig config = new EncoderConfig();
             var           res    = EncoderContextQsvDx_Open(_handle,
                                                             Core.StringToBytes(setup.Options),
                                                             ref setup.EncoderSpec,
                                                             ref setup.EncoderBitrate, setup.DirectXContext.Device.NativePointer, setup.DirectXContext.CtxNativePointer, ref config.CodecProps);
             _opened                     = res >= 0;
             _currentBitrate             = setup.EncoderBitrate;
             _dx                         = setup.DirectXContext;
             config.EncoderProps.pix_fmt = Core.PIX_FMT_INTERNAL_DIRECTX;
             Config                      = config;
             return(res);
         }
         else
         {
             return((int)ErrorCodes.ContextIsNotOpened);
         }
     }
 }
 [DllImport(Core.DllName)] private static extern void EncoderContextQsvDx_UpdateBitrate(IntPtr handle, ref EncoderBitrate encoderBitrate);
 [DllImport(Core.DllName)] private static extern int EncoderContextQsvDx_Open(IntPtr handle, byte[] options, ref EncoderSpec codecProperties, ref EncoderBitrate encoderBitrate, IntPtr device, IntPtr deviceContext, ref CodecProperties outCodecProperties);