[x265] Proposed solution to mixed 8/10 bit libraries
Steve Borho
steve at borho.org
Tue Mar 31 21:33:15 CEST 2015
Hello,
I believe I have a long term solution for the issue of having two
seperate builds for 8bpp and 16bpp of libx265. It requires a simple API
addition to x265 and then a straight-forward change to applications
which link to libx265. Once these two changes are in place, we'll have
flexibility to tackle the root problem as we see fit.
The change to the x265 API is to add a new structure and function:
typedef struct x265_api
{
x265_param* (*param_alloc)();
void (*param_free)(x265_param*);
void (*param_default)(x265_param*);
int (*param_parse)(x265_param*, const char*, const char*);
x265_encoder* (*encoder_open)(x265_param*);
.. all exported functions
int x265_max_bit_depth;
const char* x265_version_str;
const char* x265_build_info_str;
}
x265_api;
/* fill in provided x265_api structure with methods suited for
* the provided encoder parameters. If 'p' is NULL you will get
* the system default libx265 library methods */
void x265_get_api(x265_api* api, x265_param* p);
NOTE: x265_get_api will have to be versioned with X265_BUILD like
x265_encoder_encoder is.
Application which use libx265 will want to use x265_get_api() to get
their function pointers, then use x265_api.encoder_open() instead of
x265_encoder_open(), etc.
Once the application is using x265_get_api(), we can insert a shim
libx265 which determines from the param whether an 8bpp or 16bpp build
is necessary, bind the appropriate shared library (libx265_8bpp.so or
libx265_16bpp.so), and forward the call to its x265_get_api().
This could be used for more than just selecting between Main and Main10
builds, it could also select between PGO builds targeted for different
use cases (file transcode vs real-time, etc).
And if someone does eventually figure out how to build libx265 with
custom namespaces so we can statically link x265_8bpp and x265_16bpp
into a single static library, then they only need to implement an
x265_get_api() function which forwards to the appropriate namespace'd
implementation.
The user applications don't have to be aware of the multi-lib details,
and they should be able to use 8bpp and 16bpp encoders simultaneously
within the same process, if they need to.
--
Steve Borho
More information about the x265-devel
mailing list