posva / catimg

🦦 Insanely fast image printing in your terminal
http://posva.net/shell/retro/bash/2013/05/27/catimg
MIT License
1.4k stars 57 forks source link

Pull request Issue #35 nanosleep #46

Open zakgilbert opened 5 years ago

zakgilbert commented 5 years ago

Was able to get nanosleep working

int main(int argc, char *argv[])
{
    init_hash_colors();
    image_t img;
    char *file;
    char *num;
    int c;
    struct timespec req;  // <-------------  

    req.tv_sec = 0;     // <-------------
    opterr = 0;
    uint32_t cols = 0, precision = 0;
    uint8_t convert = 0;
    uint8_t true_color = 1;

Declared the timespec struct above main in catimg.c, wasn't sure where you wanted it.

struct timespec {
    time_t tv_sec;  /* seconds */       
    long   tv_nsec; /* nanoseconds */   
};

I tested multiple gifs and provided them in the test-gifs directory, goku.gif is my only concern, as hes going super sayan way quicker with the nanosleep.

I checkout the gif in gimp and the background layer is labled as Background (1000ms) as where every other layer is formated such as frame 1 (40ms) (combine). Not sure what the deal is. But besides for this, everything (all the other gifs I tested) appears to look very close to the same.

zakgilbert commented 5 years ago

Issue #35

posva commented 5 years ago

Sorry for the huge delay! I tried this on OSX and it errors out with a redefinition of time spec:

Scanning dependencies of target catimg
[ 20%] Building C object CMakeFiles/catimg.dir/src/catimg.c.o
/Users/posva/catimg/src/catimg.c:41:8: error: redefinition of 'timespec'
struct timespec {
       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types/_timespec.h:33:1: note: previous definition is here
_STRUCT_TIMESPEC
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_types/_timespec.h:29:40: note: expanded from macro '_STRUCT_TIMESPEC'
#define _STRUCT_TIMESPEC        struct timespec
                                       ^
1 error generated.
make[2]: *** [CMakeFiles/catimg.dir/src/catimg.c.o] Error 1
make[1]: *** [CMakeFiles/catimg.dir/all] Error 2
make: *** [all] Error 2

Using an #ifndef around the struct seems to make it work. Could you share the 2 or 3 of the gifs you tested with?

zakgilbert commented 5 years ago

I apologize, its been so long. First of all, this program, in my opinion, reaches into the highest branches of top notchery, so good on you @posva, most people can't reach that high.

As for myself, I'll look into this issue a bit more.

posva commented 5 years ago

No worries! Take the time you need And thank you so much for the kind words 😄

E5ten commented 4 years ago

timespec should be getting defined by time.h already, I don't see the need for defining the struct.