Skip to content

Commit 31a9ae2

Browse files
committed
🐛 fix: when the substring is longer than the original string
1 parent 2303efe commit 31a9ae2

File tree

4 files changed

+16
-23
lines changed

4 files changed

+16
-23
lines changed

README.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,9 @@ Play the video in the console as a character drawing..
88

99
![GIF](./play.gif)
1010

11-
The real-time version supports up to **720p30Hz**, the bottleneck is the encoding and decoding speed.
12-
The preloaded version supports up to **1080p30Hz**, and the bottleneck is IO.
13-
14-
| | OS | Load Mode | Decoder | Support |
15-
| - | - | - | - | - |
16-
| 0 | Windows | real-time | FFmpeg | 720p30Hz |
17-
| 1 | Linux | real-time | FFmpeg | 720p30Hz |
18-
| 2 | Windows | real-time | OpenCV | 360p15Hz |
19-
| 3 | Linux | real-time | OpenCV | 360p15Hz |
11+
### Performance
2012

13+
The real-time mode's bottleneck is the decoding speed, and the preloaded-replay mode's is IO.
2114

2215
### Help
2316

@@ -31,8 +24,8 @@ options:
3124
-o, --output [preload] output file (string [=])
3225
-a, --audio audio file (string [=])
3326
-m, --map font data file (string [=])
34-
-s, --scale width:height (string [=76:54])
35-
-r, --rate frame rate (double [=10])
27+
-s, --scale width:height (string [=72:54])
28+
-r, --rate frame rate (double [=1024])
3629
--not-clear don't clear screen (using ANSI) before print a frame
3730
--contrast-enhancement contrast Enhancement
3831
--preload [preload]
@@ -48,9 +41,7 @@ git clone --recurse-submodules --remote-submodule [email protected]:userElaina/Bad-
4841

4942
### To do
5043

51-
How to build OpenCV with MinGW-W64
52-
53-
Test
44+
Performance Test
5445

5546
### License
5647

@@ -77,7 +68,7 @@ pip install Pillow
7768
##### Interpret and Run
7869

7970
```sh
80-
python -u "font.py"
71+
python -u "font/font.py"
8172
```
8273

8374
#### Windows-FFmpeg
@@ -90,14 +81,14 @@ python -u "font.py"
9081
##### Compile and Run
9182

9283
```sh
93-
clang++ "badapple.cpp" -o "badapple.exe" -w -g -O2 -static-libgcc --target=x86_64-w64-mingw -std=c++2a
84+
clang++ "badapple.cpp" -o "badapple.exe" -w -g -O2 -static-libgcc --target=x86_64-w64-mingw
9485
./badapple
9586
```
9687

9788
or
9889

9990
```sh
100-
g++ "badapple.cpp" -o "badapple.exe" -w -g -O2 -static-libgcc -std=c++2a
91+
g++ "badapple.cpp" -o "badapple.exe" -w -g -O2 -static-libgcc
10192
./badapple
10293
```
10394

@@ -107,6 +98,8 @@ g++ "badapple.cpp" -o "badapple.exe" -w -g -O2 -static-libgcc -std=c++2a
10798

10899
[OpenCV](https://opencv.org/)
109100

101+
You may need to [compile it yourself](https://github.com/userElaina/OpenCV-460-MinGW-W64-Build).
102+
110103
##### Compile and Run
111104

112105
```sh

badapple.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ int main(int argc, char** argv) {
1212
a.add<std::string>("output", 'o', "[preload] output file", false, "");
1313
a.add<std::string>("audio", 'a', "audio file", false, "");
1414
a.add<std::string>("map", 'm', "font data file", false, "");
15-
a.add<std::string>("scale", 's', "width:height", false, "76:54");
16-
a.add<double>("rate", 'r', "frame rate", false, 10.0);
15+
a.add<std::string>("scale", 's', "width:height", false, "72:54");
16+
a.add<double>("rate", 'r', "frame rate", false, 1024.0);
1717
a.add("not-clear", '\0', "don't clear screen (using ANSI) before print a frame");
1818
a.add("contrast-enhancement", '\0', "contrast Enhancement");
1919
a.add("preload", '\0', "[preload]");

base.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#define LL long long
1111
#define B unsigned char
1212

13-
inline int endswith(std::string s,std::string sub){
14-
return s.rfind(sub)==(s.length()-sub.length())?1:0;
13+
inline int endswith(std::string s, std::string sub) {
14+
return s.rfind(sub) < s.length() && s.rfind(sub) == (s.length() - sub.length());
1515
}
1616

1717
inline void throws(const char *s) {

decode_replay.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ inline int replay(
6060
char* buffer = (char*)malloc(print_size + 2);
6161
clock_t t0, t1;
6262
#ifdef DEBUG
63-
printf("BEGINNING... [debug]\n");
63+
printf("BEGINNING... [replay] [debug]\n");
6464
fflush(stdout);
6565
second_sleep(3);
6666
#else
67-
printf("BEGINNING...\n");
67+
printf("BEGINNING... [replay]\n");
6868
fflush(stdout);
6969
second_sleep(1);
7070
#endif

0 commit comments

Comments
 (0)