What is the best way to decode X-Trans RAW?

My code looks like this:

LibRaw *rawProcessor = new LibRaw;
rawProcessor->imgdata.params.half_size = 1; // Process in half size to increase speed
rawProcessor->imgdata.params.use_camera_wb = 1;
rawProcessor->imgdata.params.use_auto_wb = 0;
rawProcessor->imgdata.params.no_auto_bright = 1;
rawProcessor->imgdata.params.exp_correc = 1;
rawProcessor->imgdata.params.exp_shift = 2.3;
rawProcessor->imgdata.params.use_rawspeed = 1;
if (rawProcessor->open_file([filePath UTF8String]) == LIBRAW_SUCCESS) {
int ret = rawProcessor->unpack();
if (ret == LIBRAW_SUCCESS) {
ret = rawProcessor->dcraw_process();
...

I'm doing a half-size extract, but I found that the resulting image looks a bit rough sometimes, especially when the photo contains some high contrast edges.

What is the best way to decode a X-Trans RAW file?

Forums: 

Use bilinear. It is fast

Use bilinear. It is fast enough (but not perfect too)

-- Alex Tutubalin @LibRaw LLC

So how do I specify bilinear

So how do I specify bilinear filter?

When I execute unpack(), does it perform demosaic of the X-Trans CFA automatically?

Kuro

unpack only unpacks raw data

unpack only unpacks raw data ('as is')
interpolation is performed on dcraw_process() step

To use bilinear set
half_size to 0
user_qual to 0

-- Alex Tutubalin @LibRaw LLC

all postprocessing is done at

all postprocessing is done at dcraw_process() step.

Unpack only unpacks (uncompress for compressed formats) raw data and stores it without any modification

-- Alex Tutubalin @LibRaw LLC