Nvjpeg Encoding method can't set to others

I want use Encoding method for example I want set encoderparams to NVJPEG_ENCODING_LOSSLESS_HUFFMAN Or NVJPEG_ENCODING_EXTENDED_SEQUENTIAL_DCT_HUFFMAN but failed the function nvjpegEncoderParamsSetEncoding return error code 2 mean invalid parameter. have any one know how to solve it?

int Encode::Create(cudaStream_t& stream,nvjpegBackend_t backend,
    int quality,
    int optimal,
    nvjpegChromaSubsampling_t subsampling,
    nvjpegJpegEncoding_t encoding)
{
    params_.stream =stream;
    nvjpegPinnedAllocator_t pinned; /*= {&host_malloc,&host_free}; */
    nvjpegDevAllocatorV2_t dev_allocator; /* = {&dev_malloc, &dev_free};*/

    CHECK_NVJPEG(nvjpegCreate(backend,NULL,&params_.handle))
    //CHECK_NVJPEG(nvjpegCreateExV2(backend,&dev_allocator,&pinned,0,&params_.handle))
   // CHECK_NVJPEG(nvjpegCreateSimple(&params_.handle))
    CHECK_NVJPEG(nvjpegEncoderStateCreate(params_.handle,&params_.encoder_state,stream))
  
    CHECK_NVJPEG(nvjpegEncoderParamsCreate(params_.handle,&params_.encoder_params,stream))

    
    CHECK_NVJPEG(nvjpegEncoderParamsSetSamplingFactors(params_.encoder_params,subsampling,stream))

    CHECK_NVJPEG(nvjpegEncoderParamsSetOptimizedHuffman(params_.encoder_params,optimal,params_.stream))
    CHECK_NVJPEG(nvjpegEncoderParamsSetEncoding(params_.encoder_params,NVJPEG_ENCODING_LOSSLESS_HUFFMAN,params_.stream))
    SetQuality(quality);
    return 0;
}