kimted9 / openjpeg

Automatically exported from code.google.com/p/openjpeg
Other
0 stars 0 forks source link

openjpeg.h shall only declare opaque C structures #439

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In order for OpenJPEG to evolve easily while keeping ABI/API compatibility, the 
public API in openjpeg.h shall only declare opaque C structures.

http://stackoverflow.com/questions/3965279/opaque-c-structs-how-should-they-be-d
eclared

Here's a simple example to illustrate the benefits :
opj_cparameters_t has only one "comment" member. J2K codestream allows for 
multiple COM markers.
With the current implementation (2.1.0), it's easy to "keep" API compatibility 
(that's assuming structure is memset to 0 or opj_set_default_encoder_parameters 
called) & get let's say 2 comments by introducing a new "comment2" member. 
However, ABI will change.

If opj_cparameters_t had been an opaque structure, the initial implementation 
to set a comment would probably have looked like this :
opj_cparameters_set_comment( opj_cparameters_t * parameters, const char* 
comment);
Now, to add support for multiple comments, openjpeg.h only would have need to 
declare a new function, let's say :
opj_cparameters_add_comment( opj_cparameters_t * parameters, const char* 
comment);

This would neither break ABI nor API compatibility (with a proper 
implementation).

Original issue reported on code.google.com by m.darb...@gmail.com on 20 Nov 2014 at 9:12

GoogleCodeExporter commented 8 years ago

Original comment by m.darb...@gmail.com on 13 May 2015 at 11:50

GoogleCodeExporter commented 8 years ago

Original comment by m.darb...@gmail.com on 13 May 2015 at 11:50