mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
switch to nc_err_e #532
This commit is contained in:
parent
5bae4f93b8
commit
ad0685aa1b
@ -856,9 +856,9 @@ namespace ncpp
|
||||
return static_cast<T*>(get_userptr ());
|
||||
}
|
||||
|
||||
Visual* visual_open (const char *file, int *averr) const
|
||||
Visual* visual_open (const char *file, nc_err_e *ncerr) const
|
||||
{
|
||||
return new Visual (plane, file, averr);
|
||||
return new Visual (plane, file, ncerr);
|
||||
}
|
||||
|
||||
NcReel* ncreel_create (const ncreel_options *popts = nullptr, int efd = -1) const
|
||||
|
@ -13,35 +13,35 @@ namespace ncpp
|
||||
class NCPP_API_EXPORT Visual : public Root
|
||||
{
|
||||
public:
|
||||
explicit Visual (Plane *plane, const char *file, int *averr)
|
||||
: Visual (reinterpret_cast<ncplane*>(plane), file, averr)
|
||||
explicit Visual (Plane *plane, const char *file, nc_err_e* ncerr)
|
||||
: Visual (reinterpret_cast<ncplane*>(plane), file, ncerr)
|
||||
{}
|
||||
|
||||
explicit Visual (Plane const* plane, const char *file, int *averr)
|
||||
: Visual (const_cast<Plane*>(plane), file, averr)
|
||||
explicit Visual (Plane const* plane, const char *file, nc_err_e* ncerr)
|
||||
: Visual (const_cast<Plane*>(plane), file, ncerr)
|
||||
{}
|
||||
|
||||
explicit Visual (Plane &plane, const char *file, int *averr)
|
||||
: Visual (reinterpret_cast<ncplane*>(&plane), file, averr)
|
||||
explicit Visual (Plane &plane, const char *file, nc_err_e* ncerr)
|
||||
: Visual (reinterpret_cast<ncplane*>(&plane), file, ncerr)
|
||||
{}
|
||||
|
||||
explicit Visual (Plane const& plane, const char *file, int *averr)
|
||||
: Visual (const_cast<Plane&>(plane), file, averr)
|
||||
explicit Visual (Plane const& plane, const char *file, nc_err_e* ncerr)
|
||||
: Visual (const_cast<Plane&>(plane), file, ncerr)
|
||||
{}
|
||||
|
||||
explicit Visual (ncplane *plane, const char *file, int *averr)
|
||||
explicit Visual (ncplane *plane, const char *file, nc_err_e* ncerr)
|
||||
{
|
||||
if (plane == nullptr)
|
||||
throw invalid_argument ("'plane' must be a valid pointer");
|
||||
|
||||
visual = ncplane_visual_open (reinterpret_cast<ncplane*>(plane), file, averr);
|
||||
visual = ncplane_visual_open (reinterpret_cast<ncplane*>(plane), file, ncerr);
|
||||
if (visual == nullptr)
|
||||
throw init_error ("notcurses failed to create a new visual");
|
||||
}
|
||||
|
||||
explicit Visual (const char *file, int *averr, int y, int x, NCScale scale)
|
||||
explicit Visual (const char *file, nc_err_e* ncerr, int y, int x, NCScale scale)
|
||||
{
|
||||
visual = ncvisual_open_plane (get_notcurses (), file, averr, y, x, static_cast<ncscale_e>(scale));
|
||||
visual = ncvisual_open_plane (get_notcurses (), file, ncerr, y, x, static_cast<ncscale_e>(scale));
|
||||
if (visual == nullptr)
|
||||
throw init_error ("notcurses failed to create a new visual");
|
||||
}
|
||||
@ -62,9 +62,9 @@ namespace ncpp
|
||||
return visual;
|
||||
}
|
||||
|
||||
AVFrame* decode (int *averr) const noexcept
|
||||
AVFrame* decode (nc_err_e* ncerr) const noexcept
|
||||
{
|
||||
return ncvisual_decode (visual, averr);
|
||||
return ncvisual_decode (visual, ncerr);
|
||||
}
|
||||
|
||||
bool render (int begy, int begx, int leny, int lenx) const NOEXCEPT_MAYBE
|
||||
@ -72,9 +72,9 @@ namespace ncpp
|
||||
return error_guard (ncvisual_render (visual, begy, begx, leny, lenx), -1);
|
||||
}
|
||||
|
||||
int stream (int *averr, float timescale, streamcb streamer, void *curry = nullptr) const NOEXCEPT_MAYBE
|
||||
int stream (nc_err_e* ncerr, float timescale, streamcb streamer, void *curry = nullptr) const NOEXCEPT_MAYBE
|
||||
{
|
||||
return error_guard<int> (ncvisual_stream (get_notcurses (), visual, averr, timescale, streamer, curry), -1);
|
||||
return error_guard<int> (ncvisual_stream (get_notcurses (), visual, ncerr, timescale, streamer, curry), -1);
|
||||
}
|
||||
|
||||
char* subtitle () const noexcept
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <notcurses/nckeys.h>
|
||||
#include <notcurses/ncerrs.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -30,7 +31,7 @@ API const char* notcurses_version(void);
|
||||
struct notcurses; // notcurses state for a given terminal, composed of ncplanes
|
||||
struct ncplane; // a drawable notcurses surface, composed of cells
|
||||
struct cell; // a coordinate on an ncplane: an EGC plus styling
|
||||
struct ncvisual; // a visual bit of multimedia opened with LibAV
|
||||
struct ncvisual; // a visual bit of multimedia opened with LibAV|OIIO
|
||||
struct ncuplot; // a histogram, bound to a plane (uint64_ts)
|
||||
struct ncdplot; // a histogram, bound to a plane (non-negative doubles)
|
||||
struct ncfdplane; // i/o wrapper to dump file descriptor to plane
|
||||
@ -2015,14 +2016,11 @@ ncplane_double_box_sized(struct ncplane* n, uint32_t attr, uint64_t channels,
|
||||
x + xlen - 1, ctlword);
|
||||
}
|
||||
|
||||
// multimedia functionality
|
||||
struct AVFrame;
|
||||
|
||||
// Open a visual (image or video), associating it with the specified ncplane.
|
||||
// Returns NULL on any error, writing the AVError to 'averr'.
|
||||
// Returns NULL on any error, writing the cause to 'ncerr'.
|
||||
// FIXME this ought also take an ncscale_e!
|
||||
API struct ncvisual* ncplane_visual_open(struct ncplane* nc, const char* file,
|
||||
int* averr);
|
||||
nc_err_e* ncerr);
|
||||
|
||||
// How to scale the visual in ncvisual_open_plane(). NCSCALE_NONE will open a
|
||||
// plane tailored to the visual's exact needs, which is probably larger than the
|
||||
@ -2042,7 +2040,7 @@ typedef enum {
|
||||
// as possible (given the visible screen), either maintaining aspect ratio
|
||||
// (NCSCALE_SCALE) or abandoning it (NCSCALE_STRETCH).
|
||||
API struct ncvisual* ncvisual_open_plane(struct notcurses* nc, const char* file,
|
||||
int* averr, int y, int x,
|
||||
nc_err_e* ncerr, int y, int x,
|
||||
ncscale_e style);
|
||||
|
||||
// Return the plane to which this ncvisual is bound.
|
||||
@ -2053,10 +2051,11 @@ API struct ncplane* ncvisual_plane(struct ncvisual* ncv);
|
||||
API void ncvisual_destroy(struct ncvisual* ncv);
|
||||
|
||||
// extract the next frame from an ncvisual. returns NULL on end of file,
|
||||
// writing AVERROR_EOF to 'averr'. returns NULL on a decoding or allocation
|
||||
// error, placing the AVError in 'averr'. this frame is invalidated by a
|
||||
// writing NCERR_EOF to 'ncerr'. returns NULL on a decoding or allocation
|
||||
// error, writing the cause to 'ncerr'. this frame is invalidated by a
|
||||
// subsequent call to ncvisual_decode(), and should not be freed by the caller.
|
||||
API struct AVFrame* ncvisual_decode(struct ncvisual* nc, int* averr);
|
||||
struct AVFrame;
|
||||
API struct AVFrame* ncvisual_decode(struct ncvisual* nc, nc_err_e* ncerr);
|
||||
|
||||
// Render the decoded frame to the associated ncplane. The frame will be scaled
|
||||
// to the size of the ncplane per the ncscale_e style. A subregion of the
|
||||
@ -2110,7 +2109,7 @@ ncvisual_simple_streamer(struct notcurses* nc, struct ncvisual* ncv, void* curry
|
||||
// 300FPS, and a 'timescale' of 10 will result in 3FPS. It is an error to
|
||||
// supply 'timescale' less than or equal to 0.
|
||||
API int ncvisual_stream(struct notcurses* nc, struct ncvisual* ncv,
|
||||
int* averr, float timescale, streamcb streamer,
|
||||
nc_err_e* ncerr, float timescale, streamcb streamer,
|
||||
void* curry);
|
||||
|
||||
// Blit a flat array 'data' of BGRx 32-bit values to the ncplane 'nc', offset
|
||||
|
@ -26,12 +26,12 @@ const char eagle1[] =
|
||||
// display the level map scaled to fit entirely within the visual area
|
||||
static int
|
||||
outzoomed_map(struct notcurses* nc, const char* map){
|
||||
int averr;
|
||||
struct ncvisual* ncv = ncvisual_open_plane(nc, map, &averr, 0, 0, NCSCALE_SCALE);
|
||||
nc_err_e ncerr;
|
||||
struct ncvisual* ncv = ncvisual_open_plane(nc, map, &ncerr, 0, 0, NCSCALE_SCALE);
|
||||
if(ncv == NULL){
|
||||
return -1;
|
||||
}
|
||||
if(ncvisual_decode(ncv, &averr) == NULL){
|
||||
if(ncvisual_decode(ncv, &ncerr) == NULL){
|
||||
return -1;
|
||||
}
|
||||
if(ncvisual_render(ncv, 0, 0, -1, -1) <= 0){
|
||||
@ -44,18 +44,18 @@ outzoomed_map(struct notcurses* nc, const char* map){
|
||||
|
||||
static struct ncplane*
|
||||
zoom_map(struct notcurses* nc, const char* map){
|
||||
int averr;
|
||||
int ncerr;
|
||||
// determine size that will be represented on screen at once, and how
|
||||
// large that section has been rendered in the outzoomed map. take the map
|
||||
// and begin opening it on larger and larger planes that fit on the screen
|
||||
// less and less. eventually, reach our natural NCSCALE_NONE size and begin
|
||||
// scrolling through the map, whooooooooosh.
|
||||
struct ncvisual* ncv = ncvisual_open_plane(nc, map, &averr, 0, 0, NCSCALE_NONE);
|
||||
struct ncvisual* ncv = ncvisual_open_plane(nc, map, &ncerr, 0, 0, NCSCALE_NONE);
|
||||
if(ncv == NULL){
|
||||
return NULL;
|
||||
}
|
||||
struct AVFrame* frame;
|
||||
if((frame = ncvisual_decode(ncv, &averr)) == NULL){
|
||||
if((frame = ncvisual_decode(ncv, &ncerr)) == NULL){
|
||||
ncvisual_destroy(ncv);
|
||||
return NULL;
|
||||
}
|
||||
@ -86,13 +86,13 @@ zoom_map(struct notcurses* nc, const char* map){
|
||||
zoomy += delty;
|
||||
zoomx += deltx;
|
||||
zncp = ncplane_new(nc, zoomy, zoomx, 0, 0, NULL);
|
||||
struct ncvisual* zncv = ncplane_visual_open(zncp, map, &averr);
|
||||
struct ncvisual* zncv = ncplane_visual_open(zncp, map, &ncerr);
|
||||
if(zncv == NULL){
|
||||
ncvisual_destroy(ncv);
|
||||
ncplane_destroy(zncp);
|
||||
return NULL;
|
||||
}
|
||||
if(ncvisual_decode(zncv, &averr) == NULL){
|
||||
if(ncvisual_decode(zncv, &ncerr) == NULL){
|
||||
ncvisual_destroy(zncv);
|
||||
ncplane_destroy(zncp);
|
||||
return NULL;
|
||||
|
@ -148,22 +148,22 @@ int luigi_demo(struct notcurses* nc){
|
||||
}
|
||||
int rows, cols;
|
||||
struct ncplane* n = notcurses_stddim_yx(nc, &rows, &cols);
|
||||
int averr = 0;
|
||||
nc_err_e ncerr = NCERR_SUCCESS;
|
||||
char* map = find_data("megaman2.bmp");
|
||||
struct ncvisual* nv = ncplane_visual_open(n, map, &averr);
|
||||
struct ncvisual* nv = ncplane_visual_open(n, map, &ncerr);
|
||||
free(map);
|
||||
if(nv == NULL){
|
||||
return -1;
|
||||
}
|
||||
if(ncvisual_decode(nv, &averr) == NULL){
|
||||
if(ncvisual_decode(nv, &ncerr) == NULL){
|
||||
return -1;
|
||||
}
|
||||
if(ncvisual_render(nv, 0, 0, -1, -1) <= 0){
|
||||
return -1;
|
||||
}
|
||||
assert(ncvisual_decode(nv, &averr) == NULL);
|
||||
assert(ncvisual_decode(nv, &ncerr) == NULL);
|
||||
#ifdef USE_FFMPEG
|
||||
assert(averr == AVERROR_EOF);
|
||||
assert(NCERR_EOF == ncerr);
|
||||
#endif
|
||||
// he should be walking on the platform ~4/5 of the way down
|
||||
const int height = 32;
|
||||
@ -190,12 +190,12 @@ int luigi_demo(struct notcurses* nc){
|
||||
if(fname == NULL){
|
||||
return -1;
|
||||
}
|
||||
wmncv = ncvisual_open_plane(nc, fname, &averr, 0, 0, NCSCALE_NONE);
|
||||
wmncv = ncvisual_open_plane(nc, fname, &ncerr, 0, 0, NCSCALE_NONE);
|
||||
free(fname);
|
||||
if(wmncv == NULL){
|
||||
return -1;
|
||||
}
|
||||
if(ncvisual_decode(wmncv, &averr) == NULL){
|
||||
if(ncvisual_decode(wmncv, &ncerr) == NULL){
|
||||
ncvisual_destroy(wmncv);
|
||||
return -1;
|
||||
}
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include <clocale>
|
||||
#include <iostream>
|
||||
#include <termios.h>
|
||||
#include <ncpp/NotCurses.hh>
|
||||
#include <ncpp/Plane.hh>
|
||||
#include <ncpp/NotCurses.hh>
|
||||
|
||||
#define NANOSECS_IN_SEC 1000000000
|
||||
|
||||
|
@ -29,16 +29,11 @@ extern "C" {
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <wctype.h>
|
||||
#include <termios.h>
|
||||
#include <stdbool.h>
|
||||
#include "notcurses/notcurses.h"
|
||||
#include "egcpool.h"
|
||||
|
||||
struct AVFormatContext;
|
||||
struct AVCodecContext;
|
||||
struct AVFrame;
|
||||
struct AVCodec;
|
||||
struct AVCodecParameters;
|
||||
struct AVPacket;
|
||||
struct SwsContext;
|
||||
struct esctrie;
|
||||
|
||||
|
@ -2,6 +2,13 @@
|
||||
#include "version.h"
|
||||
#include "internal.h"
|
||||
|
||||
struct AVFormatContext;
|
||||
struct AVCodecContext;
|
||||
struct AVFrame;
|
||||
struct AVCodec;
|
||||
struct AVCodecParameters;
|
||||
struct AVPacket;
|
||||
|
||||
typedef struct ncvisual {
|
||||
struct AVFormatContext* fmtctx;
|
||||
struct AVCodecContext* codecctx; // video codec context
|
||||
|
@ -1,22 +1,13 @@
|
||||
#include "internal.h"
|
||||
|
||||
#include "version.h"
|
||||
#ifdef USE_OIIO
|
||||
#include <OpenImageIO/imageio.h>
|
||||
#include "internal.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
typedef struct ncvisual {
|
||||
struct AVFormatContext* fmtctx;
|
||||
struct AVCodecContext* codecctx; // video codec context
|
||||
struct AVCodecContext* subtcodecctx; // subtitle codec context
|
||||
struct AVFrame* frame;
|
||||
struct AVFrame* oframe;
|
||||
struct AVCodec* codec;
|
||||
struct AVCodecParameters* cparams;
|
||||
struct AVCodec* subtcodec;
|
||||
struct AVPacket* packet;
|
||||
struct SwsContext* swsctx;
|
||||
int packet_outstanding;
|
||||
int dstwidth, dstheight;
|
||||
int stream_index; // match against this following av_read_frame()
|
||||
int sub_stream_index; // subtitle stream index, can be < 0 if no subtitles
|
||||
float timescale; // scale frame duration by this value
|
||||
ncplane* ncp;
|
||||
// if we're creating the plane based off the first frame's dimensions, these
|
||||
@ -25,40 +16,69 @@ typedef struct ncvisual {
|
||||
int placex, placey;
|
||||
ncscale_e style; // none, scale, or stretch
|
||||
struct notcurses* ncobj; // set iff this ncvisual "owns" its ncplane
|
||||
#ifdef USE_FFMPEG
|
||||
AVSubtitle subtitle;
|
||||
#endif
|
||||
} ncvisual;
|
||||
|
||||
bool notcurses_canopen(const notcurses* nc __attribute__ ((unused))){
|
||||
return true;
|
||||
}
|
||||
|
||||
ncvisual* ncplane_visual_open(ncplane* nc, const char* filename, int* averr){
|
||||
static ncvisual*
|
||||
ncvisual_create(float timescale){
|
||||
auto ret = new ncvisual;
|
||||
if(ret == nullptr){
|
||||
return nullptr;
|
||||
}
|
||||
memset(ret, 0, sizeof(*ret));
|
||||
ret->timescale = timescale;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ncvisual*
|
||||
ncvisual_open(const char* filename, nc_err_e* err){
|
||||
auto in = OIIO::ImageInput::open(filename);
|
||||
if(!in){
|
||||
return nullptr;
|
||||
}
|
||||
(void)nc;
|
||||
(void)averr;
|
||||
return NULL;
|
||||
ncvisual* ncv = ncvisual_create(1);
|
||||
if(ncv == nullptr){
|
||||
// fprintf(stderr, "Couldn't create %s (%s)\n", filename, strerror(errno));
|
||||
*err = NCERR_NOMEM;
|
||||
return nullptr;
|
||||
}
|
||||
memset(ncv, 0, sizeof(*ncv));
|
||||
return ncv;
|
||||
}
|
||||
|
||||
ncvisual* ncplane_visual_open(ncplane* nc, const char* filename, nc_err_e* ncerr){
|
||||
ncvisual* ncv = ncvisual_open(filename, ncerr);
|
||||
if(ncv == nullptr){
|
||||
return nullptr;
|
||||
}
|
||||
ncplane_dim_yx(nc, &ncv->dstheight, &ncv->dstwidth);
|
||||
ncv->dstheight *= 2;
|
||||
ncv->ncp = nc;
|
||||
ncv->style = NCSCALE_STRETCH;
|
||||
return ncv;
|
||||
}
|
||||
|
||||
ncvisual* ncvisual_open_plane(notcurses* nc, const char* filename,
|
||||
int* averr, int y, int x, ncscale_e style){
|
||||
(void)nc;
|
||||
(void)filename;
|
||||
(void)averr;
|
||||
(void)y;
|
||||
(void)x;
|
||||
(void)style;
|
||||
return NULL;
|
||||
nc_err_e* ncerr, int y, int x, ncscale_e style){
|
||||
ncvisual* ncv = ncvisual_open(filename, ncerr);
|
||||
if(ncv == nullptr){
|
||||
return nullptr;
|
||||
}
|
||||
ncv->placey = y;
|
||||
ncv->placex = x;
|
||||
ncv->style = style;
|
||||
ncv->ncobj = nc;
|
||||
ncv->ncp = nullptr;
|
||||
return ncv;
|
||||
}
|
||||
|
||||
struct AVFrame* ncvisual_decode(ncvisual* nc, int* averr){
|
||||
struct AVFrame* ncvisual_decode(ncvisual* nc, nc_err_e* ncerr){
|
||||
(void)nc;
|
||||
(void)averr;
|
||||
return NULL;
|
||||
(void)ncerr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int ncvisual_render(const ncvisual* ncv, int begy, int begx, int leny, int lenx){
|
||||
@ -70,24 +90,27 @@ int ncvisual_render(const ncvisual* ncv, int begy, int begx, int leny, int lenx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ncvisual_stream(struct notcurses* nc, struct ncvisual* ncv, int* averr,
|
||||
int ncvisual_stream(struct notcurses* nc, struct ncvisual* ncv, nc_err_e* ncerr,
|
||||
float timespec, streamcb streamer, void* curry){
|
||||
(void)nc;
|
||||
(void)ncv;
|
||||
(void)averr;
|
||||
(void)ncerr;
|
||||
(void)timespec;
|
||||
(void)streamer;
|
||||
(void)curry;
|
||||
return -1;
|
||||
}
|
||||
|
||||
char* ncvisual_subtitle(const ncvisual* ncv){
|
||||
char* ncvisual_subtitle(const ncvisual* ncv){ // no support in OIIO
|
||||
(void)ncv;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int ncvisual_init(int loglevel){
|
||||
(void)loglevel;
|
||||
return 0; // allow success here
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
#endif
|
||||
|
@ -17,12 +17,12 @@ int main(int argc, char** argv){
|
||||
int dimx, dimy;
|
||||
ncplane_dim_yx(n, &dimy, &dimx);
|
||||
|
||||
int averr;
|
||||
auto ncv = ncplane_visual_open(n, "../data/changes.jpg", &averr);
|
||||
nc_err_e ncerr;
|
||||
auto ncv = ncplane_visual_open(n, "../data/changes.jpg", &ncerr);
|
||||
if(!ncv){
|
||||
goto err;
|
||||
}
|
||||
if(!ncvisual_decode(ncv, &averr)){
|
||||
if(!ncvisual_decode(ncv, &ncerr)){
|
||||
goto err;
|
||||
}
|
||||
if(ncvisual_render(ncv, 0, 0, -1, -1) <= 0){
|
||||
|
@ -29,55 +29,55 @@ TEST_CASE("Multimedia") {
|
||||
}
|
||||
|
||||
SUBCASE("LoadImageCreatePlane") {
|
||||
int averr;
|
||||
nc_err_e ncerr;
|
||||
int dimy, dimx;
|
||||
ncplane_dim_yx(ncp_, &dimy, &dimx);
|
||||
auto ncv = ncvisual_open_plane(nc_, find_data("changes.jpg"), &averr, 0, 0, NCSCALE_STRETCH);
|
||||
auto ncv = ncvisual_open_plane(nc_, find_data("changes.jpg"), &ncerr, 0, 0, NCSCALE_STRETCH);
|
||||
REQUIRE(ncv);
|
||||
REQUIRE(0 == averr);
|
||||
auto frame = ncvisual_decode(ncv, &averr);
|
||||
REQUIRE(0 == ncerr);
|
||||
auto frame = ncvisual_decode(ncv, &ncerr);
|
||||
REQUIRE(frame);
|
||||
REQUIRE(0 == averr);
|
||||
REQUIRE(0 == ncerr);
|
||||
CHECK(dimy * 2 == frame->height);
|
||||
CHECK(dimx == frame->width);
|
||||
CHECK(0 < ncvisual_render(ncv, 0, 0, -1, -1));
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
frame = ncvisual_decode(ncv, &averr);
|
||||
frame = ncvisual_decode(ncv, &ncerr);
|
||||
REQUIRE_EQ(nullptr, frame);
|
||||
CHECK(AVERROR_EOF == averr);
|
||||
CHECK(NCERR_EOF == ncerr);
|
||||
ncvisual_destroy(ncv);
|
||||
}
|
||||
|
||||
SUBCASE("LoadImage") {
|
||||
int averr;
|
||||
nc_err_e ncerr;
|
||||
int dimy, dimx;
|
||||
ncplane_dim_yx(ncp_, &dimy, &dimx);
|
||||
auto ncv = ncplane_visual_open(ncp_, find_data("changes.jpg"), &averr);
|
||||
auto ncv = ncplane_visual_open(ncp_, find_data("changes.jpg"), &ncerr);
|
||||
REQUIRE(ncv);
|
||||
REQUIRE(0 == averr);
|
||||
auto frame = ncvisual_decode(ncv, &averr);
|
||||
REQUIRE(0 == ncerr);
|
||||
auto frame = ncvisual_decode(ncv, &ncerr);
|
||||
REQUIRE(frame);
|
||||
REQUIRE(0 == averr);
|
||||
REQUIRE(0 == ncerr);
|
||||
CHECK(dimy * 2 == frame->height);
|
||||
CHECK(dimx == frame->width);
|
||||
CHECK(0 < ncvisual_render(ncv, 0, 0, -1, -1));
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
frame = ncvisual_decode(ncv, &averr);
|
||||
frame = ncvisual_decode(ncv, &ncerr);
|
||||
REQUIRE_EQ(nullptr, frame);
|
||||
CHECK(AVERROR_EOF == averr);
|
||||
CHECK(NCERR_EOF == ncerr);
|
||||
ncvisual_destroy(ncv);
|
||||
}
|
||||
|
||||
SUBCASE("PlaneDuplicate") {
|
||||
int averr;
|
||||
nc_err_e ncerr;
|
||||
int dimy, dimx;
|
||||
ncplane_dim_yx(ncp_, &dimy, &dimx);
|
||||
auto ncv = ncplane_visual_open(ncp_, find_data("changes.jpg"), &averr);
|
||||
auto ncv = ncplane_visual_open(ncp_, find_data("changes.jpg"), &ncerr);
|
||||
REQUIRE(ncv);
|
||||
REQUIRE(0 == averr);
|
||||
auto frame = ncvisual_decode(ncv, &averr);
|
||||
REQUIRE(0 == ncerr);
|
||||
auto frame = ncvisual_decode(ncv, &ncerr);
|
||||
REQUIRE(frame);
|
||||
REQUIRE(0 == averr);
|
||||
REQUIRE(0 == ncerr);
|
||||
CHECK(dimy * 2 == frame->height);
|
||||
CHECK(dimx == frame->width);
|
||||
CHECK(0 < ncvisual_render(ncv, 0, 0, -1, -1));
|
||||
@ -96,19 +96,19 @@ TEST_CASE("Multimedia") {
|
||||
}
|
||||
|
||||
SUBCASE("LoadVideo") {
|
||||
int averr;
|
||||
nc_err_e ncerr;
|
||||
int dimy, dimx;
|
||||
ncplane_dim_yx(ncp_, &dimy, &dimx);
|
||||
auto ncv = ncplane_visual_open(ncp_, find_data("samoa.avi"), &averr);
|
||||
auto ncv = ncplane_visual_open(ncp_, find_data("samoa.avi"), &ncerr);
|
||||
REQUIRE(ncv);
|
||||
CHECK(0 == averr);
|
||||
CHECK(0 == ncerr);
|
||||
for(;;){ // run at the highest speed we can
|
||||
auto frame = ncvisual_decode(ncv, &averr);
|
||||
auto frame = ncvisual_decode(ncv, &ncerr);
|
||||
if(!frame){
|
||||
CHECK(AVERROR_EOF == averr);
|
||||
CHECK(NCERR_EOF == ncerr);
|
||||
break;
|
||||
}
|
||||
CHECK(0 == averr);
|
||||
CHECK(0 == ncerr);
|
||||
CHECK(dimy * 2 == frame->height);
|
||||
CHECK(dimx == frame->width);
|
||||
CHECK(0 < ncvisual_render(ncv, 0, 0, -1, -1));
|
||||
@ -118,15 +118,15 @@ TEST_CASE("Multimedia") {
|
||||
}
|
||||
|
||||
SUBCASE("LoadVideoCreatePlane") {
|
||||
int averr;
|
||||
nc_err_e ncerr;
|
||||
int dimy, dimx;
|
||||
ncplane_dim_yx(ncp_, &dimy, &dimx);
|
||||
auto ncv = ncvisual_open_plane(nc_, find_data("notcursesI.avi"), &averr, 0, 0, NCSCALE_STRETCH);
|
||||
auto ncv = ncvisual_open_plane(nc_, find_data("notcursesI.avi"), &ncerr, 0, 0, NCSCALE_STRETCH);
|
||||
REQUIRE(ncv);
|
||||
CHECK(0 == averr);
|
||||
auto frame = ncvisual_decode(ncv, &averr);
|
||||
CHECK(0 == ncerr);
|
||||
auto frame = ncvisual_decode(ncv, &ncerr);
|
||||
REQUIRE_NE(nullptr, frame);
|
||||
CHECK(0 == averr);
|
||||
CHECK(0 == ncerr);
|
||||
CHECK(dimy * 2 == frame->height);
|
||||
CHECK(dimx == frame->width);
|
||||
CHECK(0 < ncvisual_render(ncv, 0, 0, -1, -1));
|
||||
|
Loading…
x
Reference in New Issue
Block a user