mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
don't violate ODR with visual_implementation
This commit is contained in:
parent
822d41eb8f
commit
81f689b6a2
@ -598,6 +598,6 @@ static const ncvisual_implementation ffmpeg_impl = {
|
||||
.canopen_videos = true,
|
||||
};
|
||||
|
||||
const ncvisual_implementation* visual_implementation = &ffmpeg_impl;
|
||||
const ncvisual_implementation* local_visual_implementation = &ffmpeg_impl;
|
||||
|
||||
#endif
|
||||
|
@ -44,27 +44,6 @@ auto oiio_create() -> ncvisual* {
|
||||
return nc;
|
||||
}
|
||||
|
||||
ncvisual* oiio_from_file(const char* filename) {
|
||||
ncvisual* ncv = oiio_create();
|
||||
if(ncv == nullptr){
|
||||
return nullptr;
|
||||
}
|
||||
ncv->details->image = OIIO::ImageInput::open(filename);
|
||||
if(!ncv->details->image){
|
||||
// fprintf(stderr, "Couldn't create %s (%s)\n", filename, strerror(errno));
|
||||
ncvisual_destroy(ncv);
|
||||
return nullptr;
|
||||
}
|
||||
/*const auto &spec = ncv->details->image->spec_dimensions(0);
|
||||
std::cout << "Opened " << filename << ": " << spec.height << "x" <<
|
||||
spec.width << "@" << spec.nchannels << " (" << spec.format << ")" << std::endl;*/
|
||||
if(oiio_decode(ncv)){
|
||||
ncvisual_destroy(ncv);
|
||||
return nullptr;
|
||||
}
|
||||
return ncv;
|
||||
}
|
||||
|
||||
int oiio_decode(ncvisual* nc) {
|
||||
//fprintf(stderr, "current subimage: %d frame: %p\n", nc->details->image->current_subimage(), nc->details->frame.get());
|
||||
const auto &spec = nc->details->image->spec_dimensions(nc->details->framenum);
|
||||
@ -111,6 +90,27 @@ int oiio_decode(ncvisual* nc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ncvisual* oiio_from_file(const char* filename) {
|
||||
ncvisual* ncv = oiio_create();
|
||||
if(ncv == nullptr){
|
||||
return nullptr;
|
||||
}
|
||||
ncv->details->image = OIIO::ImageInput::open(filename);
|
||||
if(!ncv->details->image){
|
||||
// fprintf(stderr, "Couldn't create %s (%s)\n", filename, strerror(errno));
|
||||
ncvisual_destroy(ncv);
|
||||
return nullptr;
|
||||
}
|
||||
/*const auto &spec = ncv->details->image->spec_dimensions(0);
|
||||
std::cout << "Opened " << filename << ": " << spec.height << "x" <<
|
||||
spec.width << "@" << spec.nchannels << " (" << spec.format << ")" << std::endl;*/
|
||||
if(oiio_decode(ncv)){
|
||||
ncvisual_destroy(ncv);
|
||||
return nullptr;
|
||||
}
|
||||
return ncv;
|
||||
}
|
||||
|
||||
int ncvisual_decode_loop(ncvisual* ncv){
|
||||
int r = oiio_decode(ncv);
|
||||
if(r == 1){
|
||||
@ -282,6 +282,6 @@ const static ncvisual_implementation oiio_impl = {
|
||||
.canopen_videos = false,
|
||||
};
|
||||
|
||||
const ncvisual_implementation* visual_implementation = &oiio_impl;
|
||||
const ncvisual_implementation* local_visual_implementation = &oiio_impl;
|
||||
|
||||
#endif
|
||||
|
@ -1,10 +1,14 @@
|
||||
#include "notcurses/direct.h"
|
||||
#include "internal.h"
|
||||
|
||||
extern const ncvisual_implementation* local_visual_implementation;
|
||||
|
||||
ncdirect* ncdirect_init(const char* termtype, FILE* outfp, uint64_t flags){
|
||||
visual_implementation = local_visual_implementation;
|
||||
return ncdirect_core_init(termtype, outfp, flags);
|
||||
}
|
||||
|
||||
notcurses* notcurses_init(const notcurses_options* opts, FILE* outfp){
|
||||
visual_implementation = local_visual_implementation;
|
||||
return notcurses_core_init(opts, outfp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user