#include — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #include, aggregated by home.social.
-
Japan gold exports hit record $25bn, likely include metal once smuggled in
Commodities Fiscal 2025 outflow due to higher prices abroad on geopolitical tensions As international gold prices rise, ingots are leaving Japan. © Reuters TOKYO — Japan’s gold exports surpassed 4 trillion yen ($25 bill…
#Japan #JP #JapanNews #$25bn #exports #gold #Hit #include #likely #metal #news #record #smuggled
https://www.alojapan.com/1490327/japan-gold-exports-hit-record-25bn-likely-include-metal-once-smuggled-in/ -
Japan gold exports hit record $25bn, likely include metal once smuggled in
Commodities Fiscal 2025 outflow due to higher prices abroad on geopolitical tensions As international gold prices rise, ingots are leaving Japan. © Reuters TOKYO — Japan’s gold exports surpassed 4 trillion yen ($25 bill…
#Japan #JP #JapanNews #$25bn #exports #gold #Hit #include #likely #metal #news #record #smuggled
https://www.alojapan.com/1490327/japan-gold-exports-hit-record-25bn-likely-include-metal-once-smuggled-in/ -
https://www.alojapan.com/1490327/japan-gold-exports-hit-record-25bn-likely-include-metal-once-smuggled-in/ Japan gold exports hit record $25bn, likely include metal once smuggled in #$25bn #exports #gold #Hit #include #Japan #JapanNews #likely #metal #news #record #smuggled Commodities Fiscal 2025 outflow due to higher prices abroad on geopolitical tensions As international gold prices rise, ingots are leaving Japan. © Reuters TOKYO — Japan’s gold exports surpassed 4 trillion yen ($25 billion) for the first time in fiscal 2025, driven by rising pr
-
https://www.alojapan.com/1490327/japan-gold-exports-hit-record-25bn-likely-include-metal-once-smuggled-in/ Japan gold exports hit record $25bn, likely include metal once smuggled in #$25bn #exports #gold #Hit #include #Japan #JapanNews #likely #metal #news #record #smuggled Commodities Fiscal 2025 outflow due to higher prices abroad on geopolitical tensions As international gold prices rise, ingots are leaving Japan. © Reuters TOKYO — Japan’s gold exports surpassed 4 trillion yen ($25 billion) for the first time in fiscal 2025, driven by rising pr
-
@SRAZKVT well, you get into interesting library design philosophy questions there
a well-designed library interface for any feature shouldn't leave the user needing to think about how its macros expand any more than they usually should think about what lies behind a function call boundary - which is a non-zero amount of the time but it is comparatively very low
(obviously anything built with
#include INCREMENTfailed hard at the first hurdle but ygwim) -
CW: re: a quine in C23
@typeswitch I have a similar one in C99, it uses #include __FILE__
-
@david_chisnall @FritzAdalis What about #include and #define ? I love those tags...
-
@david_chisnall @FritzAdalis What about #include and #define ? I love those tags...
-
@david_chisnall @FritzAdalis What about #include and #define ? I love those tags...
-
@david_chisnall @FritzAdalis What about #include and #define ? I love those tags...
-
@david_chisnall @FritzAdalis What about #include and #define ? I love those tags...
-
God damn.... you're one smart cookie. But I wonder how you did in compiler design?
#include <stdio.h>
#include <stdlib.h>int main() {
int *p = malloc(sizeof(int));
*p = 42;
free(p);printf("%d\n", *p); // memory has been freed — we're reading garbage or worse
*p = 100; // writing into memory we no longer ownreturn 0;
}_______
Care to elaborate?
-
$ woman 2 siscall siscall(2) Sister Calls Manual siscall(2) NAME siscall - indirect sister call LIBRARY Standard C library (libc, -lc) SYNOPSIS #include <sis/siscall.h> /* Definition of SIS_* constants */ #include <unistd.h> long siscall(long number, ...); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): siscall(): Since glibc 2.19: _DEFAULT_SOURCE Before glibc 2.19: _BSD_SOURCE || _SVID_SOURCE -
include: bitstring.h
kre: PR lib/60249 add some casts, and #include <stdlib.h>
http://cvsweb.netbsd.org/bsdweb.cgi/src/include/bitstring.h.diff?r1=1.15&r2=1.16
-
Got the keyboard vfd to do custom character glyphs :)
Following little bit of userland cpp code does the thing when my dekokbd kernel driver is loaded:
happy_sad.cpp
```
#include <filesystem>
#include <fstream>
#include <iostream>
#include <stdexcept>static const std::filesystem::path devicePath{"/dev/dekovfd"};
unsigned char glyph_smile[8] = {
0b11011,
0b11011,
0b00000,
0b00000,
0b11111,
0b01110,
0b00000,
0b00000
};unsigned char glyph_frown[8] = {
0b11011,
0b11011,
0b00000,
0b00000,
0b01110,
0b11011,
0b00000,
0b00000
};enum class VfdBrightness : char {
Dim = 0x03,
Medium = 0x02,
Bright = 0x01,
VeryBright = 0x00
};/// Clears the screen of the VFD display.
void clear_screen(std::ofstream& deviceStream)
{
deviceStream << "\xe4\x01";
}/// Sends cursor to row 1, line 1.
void cursor_home(std::ofstream& deviceStream)
{
deviceStream << "\xe4\x02";
}/// Moves cursor left 1 space.
void cursor_left(std::ofstream& deviceStream)
{
deviceStream << "\xe4\x10";
}/// Moves cursor right 1 space.
void cursor_right(std::ofstream& deviceStream)
{
deviceStream << "\xe4\x14";
}/**
* Sends the cursor to a specific position.
*
* @param deviceStream the device to write to.
* @param y Should be either 0 or 1.
* @param x Visible characters range between 0 and 19,
* but there's a hidden buffer behind it up to 39
* (useful for scroll effects or instant paging).
*/
void gotoxy(std::ofstream& deviceStream, int x, int y)
{
unsigned char address{};
if (x < 0) x = 0;
if (x > 39) x = 39;
address = y <= 0 ? 0x80 + x : 0xc0 + x;
deviceStream << "\xe4" << static_cast<char>(address);
}/**
* Shifts the entire contents of the vfd display to the left.
*
* It will also shift the hidden off-screen buffer onto the
* screen this way.
*/
void shift_display_left(std::ofstream& deviceStream)
{
deviceStream << "\xe4\x18";
}/**
* Shifts the entire contents of the vfd display to the left.
*
* It will also shift screen contents into the hidden off-screen
* buffer this way.
*/
void shift_display_right(std::ofstream& deviceStream)
{
deviceStream << "\xe4\x1c";
}/// Turns the vfd display on.
void display_on(std::ofstream& deviceStream)
{
deviceStream << "\xe4\x0c";
}/// Makes the cursor visible on the vfd display.
void cursor_on(std::ofstream& deviceStream)
{
deviceStream << "\xe4\x0e";
}/// Makes the cursor visible and makes it blink.
void cursor_on_blinking(std::ofstream& deviceStream)
{
deviceStream << "\xe4\x0f";
}/// Turns the vfd display off.
void display_off(std::ofstream& deviceStream)
{
deviceStream << "\xe4\x08";
}/**
* Enable 8-bits per character mode.
*
* The display can also operate in a 4-bits per character
* mode, and when it's in that mode, you'll get garbage on the
* screen when trying to write normal text. This forces the
* vfd into normal 8-bit mode.
*/
void display_8bit(std::ofstream& deviceStream)
{
deviceStream << "\xe4\x38";
deviceStream << "\xe4\x38";
deviceStream << "\xe4\x38";
}/**
* Set vfd display brightness.
*
* @param deviceStream the device to write to.
* @param brightness The desired screen brightness.
*/
void display_brightness(std::ofstream& deviceStream, VfdBrightness brightness)
{
deviceStream << "\xe4\x38\xe6" << static_cast<const char>(brightness);
}/**
* Stores a custom glyph in one of the 8 UDF slots.
*
* @param deviceStream The device to write to.
* @param slot The custom character slot (0 through 7, the vfd can store up to 8 custom glyphs)
* @param data A pointer to 8 bytes of pixel data (5 bits used per byte)
*/
void define_custom_char(std::ofstream& deviceStream, int slot, const unsigned char* data)
{
std::string buff{};if (slot < 0 || slot > 7)
{
throw std::runtime_error("Invalid slot passed to define_custom_char().");
}buff.reserve(18);
buff.push_back('\xe4');
buff.push_back(static_cast<char>(0x40 + (slot * 8)));for (int i = 0; i < 8; ++i)
{
buff.push_back('\xe6');
buff.push_back(static_cast<char>(data[i]));
}
deviceStream.write(buff.data(), buff.size());
}/// Entry point
int main(int argc, char* argv[])
{if (!std::filesystem::exists(devicePath))
{
std::cerr << devicePath.string() << " does not exist." << std::endl;
return 1;
}std::ofstream deviceStream(devicePath);
if (!deviceStream.is_open())
{
std::cerr << "Could not open " << devicePath.string() << "\n";
return 1;
}/* This is a bit of an initialization dance, to make sure everything works
no matter what state the vfd is in.
First we mke sure the display is in 8-bit character mode instead of the
weird 4-bit character mode, then we make sure the display is on, and has
the right brightness set etc... */
display_8bit(deviceStream);
display_on(deviceStream);
display_brightness(deviceStream, VfdBrightness::VeryBright);
deviceStream.flush();define_custom_char(deviceStream, 1, glyph_smile);
define_custom_char(deviceStream, 2, glyph_frown);
deviceStream.flush();clear_screen(deviceStream);
cursor_home(deviceStream);
deviceStream.flush();deviceStream << "Happy: (\1)";
gotoxy(deviceStream, 0, 1);
deviceStream << "Sad: (\2)";return 0;
}```
-
Europe without Turkey ‘Incomplete, Vulnerable in Managing Crises: Erdogan
Islam Times – Turkish President Recep Tayyip Erdogan said on Saturday that a European architecture that does not…
#Europe #EU #‘Incomplete #a #and #Architecture #Crises #does #Erdogan #European #in #include #Islam #its #Managing #not #on #place #President #Recep #remain #rightful #said #Saturday #Tayyip #that #Times #turkey #Turkish #vulnerable #without #would
https://www.europesays.com/europe/36773/ -
RE: https://mastodon.social/@zadjii/116518329631639405
One of the measurements that I've taken for my latest talk:
The *entire* API (i.e. header files) of Asio, Boost, Ceral, Eigen, Qt, Xerces, plus MS MFC, MS STL, MS Windows SDK, MS UCRT
* compiled as #include, or loaded from PCH: 2 GB
* compiled as modules (one for each library) and imported: 88 MB
-
CW: C/C++ hot take
as far as I can tell header files have no advantages over just putting your forward declarations at the top of your
.c/.cppfileslike it’s bad enough that you have to declare everything twice, but putting your second declaration in a totally separate file that you have to remember to keep updated? that will definitely bite you in the ass
also the existence of header files requires you to use some arcane rube goldberg build system like
makethat’s held together with chewing gum and rubber bands, and probably isn’t even portable. when instead you could literally just include your.c/.cppfiles directly and bypass that whole processand it’s not even hard to write a
.c/.cppfile that doesn’t need a headerfile:// inside of funcs.cpp: #ifndef FUNCS_CPP #define FUNCS_CPP int someFunc(); int someFunc() { return 666; } #endif // and you just import it like this: #include "./funcs.cpp"like why didn’t people figure this out decades ago. who even thought that headerfiles were a good idea. maybe I’m missing something but they genuinely seem to have only downsides and aren’t even the obvious way to solve this problem?
-
CW: C/C++ hot take
as far as I can tell header files have no advantages over just putting your forward declarations at the top of your
.c/.cppfileslike it’s bad enough that you have to declare everything twice, but putting your second declaration in a totally separate file that you have to remember to keep updated? that will definitely bite you in the ass
also the existence of header files requires you to use some arcane rube goldberg build system like
makethat’s held together with chewing gum and rubber bands, and probably isn’t even portable. when instead you could literally just include your.c/.cppfiles directly and bypass that whole processand it’s not even hard to write a
.c/.cppfile that doesn’t need a headerfile:// inside of funcs.cpp: #ifndef FUNCS_CPP #define FUNCS_CPP int someFunc(); int someFunc() { return 666; } #endif // and you just import it like this: #include "./funcs.cpp"like why didn’t people figure this out decades ago. who even thought that headerfiles were a good idea. maybe I’m missing something but they genuinely seem to have only downsides and aren’t even the obvious way to solve this problem?
-
CW: C/C++ hot take
as far as I can tell header files have no advantages over just putting your forward declarations at the top of your
.c/.cppfileslike it’s bad enough that you have to declare everything twice, but putting your second declaration in a totally separate file that you have to remember to keep updated? that will definitely bite you in the ass
also the existence of header files requires you to use some arcane rube goldberg build system like
makethat’s held together with chewing gum and rubber bands, and probably isn’t even portable. when instead you could literally just include your.c/.cppfiles directly and bypass that whole processand it’s not even hard to write a
.c/.cppfile that doesn’t need a headerfile:// inside of funcs.cpp: #ifndef FUNCS_CPP #define FUNCS_CPP int someFunc(); int someFunc() { return 666; } #endif // and you just import it like this: #include "./funcs.cpp"like why didn’t people figure this out decades ago. who even thought that headerfiles were a good idea. maybe I’m missing something but they genuinely seem to have only downsides and aren’t even the obvious way to solve this problem?
-
CW: C/C++ hot take
as far as I can tell header files have no advantages over just putting your forward declarations at the top of your
.c/.cppfileslike it’s bad enough that you have to declare everything twice, but putting your second declaration in a totally separate file that you have to remember to keep updated? that will definitely bite you in the ass
also the existence of header files requires you to use some arcane rube goldberg build system like
makethat’s held together with chewing gum and rubber bands, and probably isn’t even portable. when instead you could literally just include your.c/.cppfiles directly and bypass that whole processand it’s not even hard to write a
.c/.cppfile that doesn’t need a headerfile:// inside of funcs.cpp: #ifndef FUNCS_CPP #define FUNCS_CPP int someFunc(); int someFunc() { return 666; } #endif // and you just import it like this: #include "./funcs.cpp"like why didn’t people figure this out decades ago. who even thought that headerfiles were a good idea. maybe I’m missing something but they genuinely seem to have only downsides and aren’t even the obvious way to solve this problem?
-
CW: C/C++ hot take
as far as I can tell header files have no advantages over just putting your forward declarations at the top of your
.c/.cppfileslike it’s bad enough that you have to declare everything twice, but putting your second declaration in a totally separate file that you have to remember to keep updated? that will definitely bite you in the ass
also the existence of header files requires you to use some arcane rube goldberg build system like
makethat’s held together with chewing gum and rubber bands, and probably isn’t even portable. when instead you could literally just include your.c/.cppfiles directly and bypass that whole processand it’s not even hard to write a
.c/.cppfile that doesn’t need a headerfile:// inside of funcs.cpp: #ifndef FUNCS_CPP #define FUNCS_CPP int someFunc(); int someFunc() { return 666; } #endif // and you just import it like this: #include "./funcs.cpp"like why didn’t people figure this out decades ago. who even thought that headerfiles were a good idea. maybe I’m missing something but they genuinely seem to have only downsides and aren’t even the obvious way to solve this problem?
-
common/dist/zlib: zutil.h
kre: No #include <userland.header> in KERNEL or STANDALONE
http://cvsweb.netbsd.org/bsdweb.cgi/src/common/dist/zlib/zutil.h.diff?r1=1.9&r2=1.10
-
CW: very cursed LLM stuff
One of the major downsides of vibecoding is that once the code has been written by the AI it is deterministically right or wrong and also cannot be improved (e.g. by switching to a new frontier model) without manually prompting an AI to rewrite it.
Therefore, I have decided to address these issues by developing a new and revolutionary file system:
llmfs!Simply point it to an API, mount it somewhere, and start following "everything is a file"! Even your LLM prompts!
With this amazing new, never-before-seen technology, you can simply include prompts into your C(++) code using the well-known
#includekeyword:#include <string.h> #include <stdio.h> #include <stdlib.h> #include "llm/openai/gpt-oss-20b/prompt/Write a C function called 'void replace(char* text, const char* needle, const char* replacement)' \ that replaces all occurences of needle with replacement. Only include the function and no markdown or explanation." int main() { const char* str = "Hello World!"; char* s = strdup(str); replace(s, "Hello", "Goodbye"); printf("%s\n", s); return 0; }Will your code compile? Maybe.
Will your code work? Who knows!
Will your code have the same behavior every time you compile it? Abso-fucking-lutely not!
Will your code burn through tons and tons of tokens? Abso-fucking-lutely yes, so you can finally hit those CEO-mandated token goals.
Can you see your code? No.
Does the compiler show your code if there are warnings or errors? No, it generates an entirely new version for diagnosis!
Is this real? Yes, it exists and runs on my machine!
Does it actually work? Sometimes!
#AI #LLM #FUSE3 #cursed #I-am-so-sorry-for-creating-this #include #include #include #include #include -
CW: very cursed LLM stuff
One of the major downsides of vibecoding is that once the code has been written by the AI it is deterministically right or wrong and also cannot be improved (e.g. by switching to a new frontier model) without manually prompting an AI to rewrite it.
Therefore, I have decided to address these issues by developing a new and revolutionary file system:
llmfs!Simply point it to an API, mount it somewhere, and start following "everything is a file"! Even your LLM prompts!
With this amazing new, never-before-seen technology, you can simply include prompts into your C(++) code using the well-known
#includekeyword:#include <string.h> #include <stdio.h> #include <stdlib.h> #include "llm/openai/gpt-oss-20b/prompt/Write a C function called 'void replace(char* text, const char* needle, const char* replacement)' \ that replaces all occurences of needle with replacement. Only include the function and no markdown or explanation." int main() { const char* str = "Hello World!"; char* s = strdup(str); replace(s, "Hello", "Goodbye"); printf("%s\n", s); return 0; }Will your code compile? Maybe.
Will your code work? Who knows!
Will your code have the same behavior every time you compile it? Abso-fucking-lutely not!
Will your code burn through tons and tons of tokens? Abso-fucking-lutely yes, so you can finally hit those CEO-mandated token goals.
Can you see your code? No.
Does the compiler show your code if there are warnings or errors? No, it generates an entirely new version for diagnosis!
Is this real? Yes, it exists and runs on my machine!
Does it actually work? Sometimes!
#AI #LLM #FUSE3 #cursed #I-am-so-sorry-for-creating-this #include #include #include #include #include -
CW: very cursed LLM stuff
One of the major downsides of vibecoding is that once the code has been written by the AI it is deterministically right or wrong and also cannot be improved (e.g. by switching to a new frontier model) without manually prompting an AI to rewrite it.
Therefore, I have decided to address these issues by developing a new and revolutionary file system:
llmfs!Simply point it to an API, mount it somewhere, and start following "everything is a file"! Even your LLM prompts!
With this amazing new, never-before-seen technology, you can simply include prompts into your C(++) code using the well-known
#includekeyword:#include <string.h> #include <stdio.h> #include <stdlib.h> #include "llm/openai/gpt-oss-20b/prompt/Write a C function called 'void replace(char* text, const char* needle, const char* replacement)' \ that replaces all occurences of needle with replacement. Only include the function and no markdown or explanation." int main() { const char* str = "Hello World!"; char* s = strdup(str); replace(s, "Hello", "Goodbye"); printf("%s\n", s); return 0; }Will your code compile? Maybe.
Will your code work? Who knows!
Will your code have the same behavior every time you compile it? Abso-fucking-lutely not!
Will your code burn through tons and tons of tokens? Abso-fucking-lutely yes, so you can finally hit those CEO-mandated token goals.
Can you see your code? No.
Does the compiler show your code if there are warnings or errors? No, it generates an entirely new version for diagnosis!
Is this real? Yes, it exists and runs on my machine!
Does it actually work? Sometimes!
#AI #LLM #FUSE3 #cursed #I-am-so-sorry-for-creating-this #include #include #include #include #include -
CW: very cursed LLM stuff
One of the major downsides of vibecoding is that once the code has been written by the AI it is deterministically right or wrong and also cannot be improved (e.g. by switching to a new frontier model) without manually prompting an AI to rewrite it.
Therefore, I have decided to address these issues by developing a new and revolutionary file system:
llmfs!Simply point it to an API, mount it somewhere, and start following "everything is a file"! Even your LLM prompts!
With this amazing new, never-before-seen technology, you can simply include prompts into your C(++) code using the well-known
#includekeyword:#include <string.h> #include <stdio.h> #include <stdlib.h> #include "llm/openai/gpt-oss-20b/prompt/Write a C function called 'void replace(char* text, const char* needle, const char* replacement)' \ that replaces all occurences of needle with replacement. Only include the function and no markdown or explanation." int main() { const char* str = "Hello World!"; char* s = strdup(str); replace(s, "Hello", "Goodbye"); printf("%s\n", s); return 0; }Will your code compile? Maybe.
Will your code work? Who knows!
Will your code have the same behavior every time you compile it? Abso-fucking-lutely not!
Will your code burn through tons and tons of tokens? Abso-fucking-lutely yes, so you can finally hit those CEO-mandated token goals.
Can you see your code? No.
Does the compiler show your code if there are warnings or errors? No, it generates an entirely new version for diagnosis!
Is this real? Yes, it exists and runs on my machine!
Does it actually work? Sometimes!
#AI #LLM #FUSE3 #cursed #I-am-so-sorry-for-creating-this #include #include #include #include #include -
CW: very cursed LLM stuff
One of the major downsides of vibecoding is that once the code has been written by the AI it is deterministically right or wrong and also cannot be improved (e.g. by switching to a new frontier model) without manually prompting an AI to rewrite it.
Therefore, I have decided to address these issues by developing a new and revolutionary file system:
llmfs!Simply point it to an API, mount it somewhere, and start following "everything is a file"! Even your LLM prompts!
With this amazing new, never-before-seen technology, you can simply include prompts into your C(++) code using the well-known
#includekeyword:#include <string.h> #include <stdio.h> #include <stdlib.h> #include "llm/openai/gpt-oss-20b/prompt/Write a C function called 'void replace(char* text, const char* needle, const char* replacement)' \ that replaces all occurences of needle with replacement. Only include the function and no markdown or explanation." int main() { const char* str = "Hello World!"; char* s = strdup(str); replace(s, "Hello", "Goodbye"); printf("%s\n", s); return 0; }Will your code compile? Maybe.
Will your code work? Who knows!
Will your code have the same behavior every time you compile it? Abso-fucking-lutely not!
Will your code burn through tons and tons of tokens? Abso-fucking-lutely yes, so you can finally hit those CEO-mandated token goals.
Can you see your code? No.
Does the compiler show your code if there are warnings or errors? No, it generates an entirely new version for diagnosis!
Is this real? Yes, it exists and runs on my machine!
Does it actually work? Sometimes!
#AI #LLM #FUSE3 #cursed #I-am-so-sorry-for-creating-this #include #include #include #include #include -
It's live.
https://godbolt.org/z/71f3xxcYh
#include <stdio.h>
#define bar(x) _Generic(x, \
int v: v, \
struct foo v: v.name \
)
struct foo { char* name; };
int main() {
struct foo f = { "test" };
bar(3);
bar(f) = "something";
puts(f.name); // prints "something"
} -
I've added `#include "functional"` to FlipperTransportTypes.h a really surprising number of times for someone who doesn't know what the hell Flipper is.
-
No warranty implied, use at your own risk. But this short C program can check if your Linux machine is still vulnerable to Copy Fail (there's also this page with python code from our friends in Estonia https://docs.hpc.ut.ee/public/cve-2026-31431/ )
Output includes "ARE available" or "NOT available"
Again: compile and run at your own risk. Don't just trust me blindly. Read the code. #CopyFail #CVE-2026-31431
==============#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/socket.h>
#include <linux/if_alg.h>int main(void) {
int sock;
struct sockaddr_alg sa;// Prepare sockaddr_alg for AEAD/GCM
memset(&sa, 0, sizeof(sa));
sa.salg_family = AF_ALG;
strcpy((char *)sa.salg_type, "aead");
strcpy((char *)sa.salg_name, "gcm(aes)");// Try to create AF_ALG socket
sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
if (sock == -1) {
perror("socket(AF_ALG, aead)");
printf("algif_aead functions are NOT available (AF_ALG socket creation failed).\n");
return 1;
}// Try to bind to AEAD/GCM
if (bind(sock, (struct sockaddr *)&sa, sizeof(sa)) == -1) {
perror("bind(AF_ALG, aead, gcm(aes))");
printf("algif_aead functions are NOT available (bind failed).\n");
close(sock);
return 1;
}printf("algif_aead functions ARE available (AF_ALG AEAD bind succeeded).\n");
close(sock);
return 0;
} -
-
-
formatting and printing values in C++ seems nice and normal and not insane at all 🙃
#include <iostream> #include <iomanip> using namespace std; int main() { cout << fixed << showpoint << setprecision(2) << setw(9) << 34.789 << endl; cout << fixed << showpoint << setprecision(3) << setw(5) << 7.0 << endl; cout << fixed << noshowpoint << 5.789e12 << endl; cout << left << setw(7) << 67 << endl; } -
RE: https://infosec.exchange/@lcamtuf/116468047421602214
Are you fucking kidding me? Of course they're making it even worse...
> #include <https://lcamtuf.coredump.cx/leftpad.h>
Oh would be a shame when we ship every 10th downloader (or based upon "marketingers microtargeting data") a different header file that includes a backdoor, wouldn't it?
(Also based upon the last sentence it is clear this is satire, but these days we also have "vibecoding" which previously was only a meme too, so...)
-
-
@lcamtuf This is just a clunkier implementation of
>>>myprog.c
#include "/dev/stdin"
...
<<<
curl http://example.com/software.c | gcc myprog.c -
diff --git a/lix/libfetchers/github.cc b/lix/libfetchers/github.cc
index fdb0727f1e..cb8345115c 100644
--- a/lix/libfetchers/github.cc
+++ b/lix/libfetchers/github.cc
@@ -14,6 +14,20 @@
#include <optional>
#include <fstream>
+#include <cctype>
+#include <algorithm>
+#include <string_view>
+
+bool ichar_equals(char a, char b)
+{
+ return std::tolower(static_cast<unsigned char>(a)) ==
+ std::tolower(static_cast<unsigned char>(b));
+}
+
+bool iequals(std::string_view lhs, std::string_view rhs)
+{
+ return std::ranges::equal(lhs, rhs, ichar_equals);
+}
namespace nix::fetchers {
@@ -178,6 +192,10 @@
}
if (ref) {
path += "/" + *ref;
+ if (iequals(repo, "nixpkgs") && iequals(owner, "nixos")) {
+ // GitHub is slow.
+ printTaggedWarning("GitHub is slow, consider using https://channels.nixos.org/%s/nixexprs.tar.xz as an input instead", *ref);
+ }
}
if (rev) {
path += "/" + rev->to_string(HashFormat::Base16, false); -
ゴミは速やかにゴミ箱へ
Світе, швидко викидай своє сміття у смітник.
Інакше настане червона зима.https://www.deviantart.com/poison-raika/art/Gomi-wa-Sumiyaka-ni-Komibako-e-1228640282
<>
#trash #immediately #priority #essential #include #people #specific #example #certain #Hanafuda #President #more #Emperor #mercy #currently #impose #death #sentence #Ukraine #world #blind #eye #contamination #touche #result
-
ゴミは速やかにゴミ箱へ
Світе, швидко викидай своє сміття у смітник.
Інакше настане червона зима.https://www.deviantart.com/poison-raika/art/Gomi-wa-Sumiyaka-ni-Komibako-e-1228640282
<>
#trash #immediately #priority #essential #include #people #specific #example #certain #Hanafuda #President #more #Emperor #mercy #currently #impose #death #sentence #Ukraine #world #blind #eye #contamination #touche #result
-
ゴミは速やかにゴミ箱へ
Світе, швидко викидай своє сміття у смітник.
Інакше настане червона зима.https://www.deviantart.com/poison-raika/art/Gomi-wa-Sumiyaka-ni-Komibako-e-1228640282
<>
#trash #immediately #priority #essential #include #people #specific #example #certain #Hanafuda #President #more #Emperor #mercy #currently #impose #death #sentence #Ukraine #world #blind #eye #contamination #touche #result
-
ゴミは速やかにゴミ箱へ
Світе, швидко викидай своє сміття у смітник.
Інакше настане червона зима.https://www.deviantart.com/poison-raika/art/Gomi-wa-Sumiyaka-ni-Komibako-e-1228640282
<>
#trash #immediately #priority #essential #include #people #specific #example #certain #Hanafuda #President #more #Emperor #mercy #currently #impose #death #sentence #Ukraine #world #blind #eye #contamination #touche #result
-
CW: C++
#include "util/ffmpeg_movie_writer.h"
#include <godot_cpp/classes/image.hpp>
#ifdef FFMPEG_AVAILABLE
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswresample/swresample.h>
#include <libswscale/swscale.h>
}
#endif
void FFmpegMovieWriter::_bind_methods() {
}
uint32_t FFmpegMovieWriter::_get_audio_mix_rate() const {
return 48000;
}
AudioServer::SpeakerMode FFmpegMovieWriter::_get_audio_speaker_mode() const {
return AudioServer::SPEAKER_MODE_STEREO;
}
bool FFmpegMovieWriter::_handles_file(const String &p_path) const {
return p_path.get_extension().to_lower() == "mkv";
}
PackedStringArray FFmpegMovieWriter::_get_supported_extensions() const {
return { "mkv" };
}
Error FFmpegMovieWriter::_write_begin(const Vector2i &p_movie_size, uint32_t p_fps, const String &p_base_path) {
#ifdef FFMPEG_AVAILABLE
int error = avformat_alloc_output_context2(&_context, nullptr, "matroska", p_base_path.utf8().get_data());
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
const AVCodec *video_codec = avcodec_find_encoder(AV_CODEC_ID_AV1);
ERR_FAIL_NULL_V_MSG(video_codec, FAILED, "ffmpeg was not compiled with AV1 support");
_video_context = avcodec_alloc_context3(video_codec);
ERR_FAIL_NULL_V_MSG(_video_context, FAILED, "failed to allocate video context");
_video_context->time_base = av_make_q(1, p_fps);
_video_context->framerate = av_make_q(p_fps, 1);
_video_context->width = p_movie_size.x;
_video_context->height = p_movie_size.y;
_video_context->sample_aspect_ratio = av_make_q(1, 1);
_video_context->pix_fmt = AV_PIX_FMT_YUV420P;
AVDictionary *video_options = nullptr;
av_dict_set_int(&video_options, "crf", 30, 0);
error = avcodec_open2(_video_context, video_codec, &video_options);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
av_dict_free(&video_options);
_video_stream = avformat_new_stream(_context, video_codec);
ERR_FAIL_NULL_V_MSG(_video_stream, FAILED, "failed to create video stream");
error = avcodec_parameters_from_context(_video_stream->codecpar, _video_context);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
const AVCodec *audio_codec = avcodec_find_encoder(AV_CODEC_ID_OPUS);
ERR_FAIL_NULL_V_MSG(audio_codec, FAILED, "ffmpeg was not compiled with Opus support");
_audio_context = avcodec_alloc_context3(audio_codec);
ERR_FAIL_NULL_V_MSG(_audio_context, FAILED, "failed to allocate audio context");
_audio_context->bit_rate = 96000;
_audio_context->time_base = av_make_q(1, 48000);
_audio_context->sample_rate = 48000;
_audio_context->sample_fmt = AV_SAMPLE_FMT_S16;
_audio_context->ch_layout = AV_CHANNEL_LAYOUT_STEREO;
error = avcodec_open2(_audio_context, audio_codec, nullptr);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
_audio_stream = avformat_new_stream(_context, audio_codec);
ERR_FAIL_NULL_V_MSG(_audio_stream, FAILED, "failed to create audio stream");
error = avcodec_parameters_from_context(_audio_stream->codecpar, _audio_context);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
_image_frame = av_frame_alloc();
ERR_FAIL_NULL_V_MSG(_image_frame, FAILED, "failed to create image frame");
_image_frame->width = p_movie_size.x;
_image_frame->height = p_movie_size.y;
_image_frame->format = AV_PIX_FMT_RGBA;
_image_frame->sample_aspect_ratio = av_make_q(1, 1);
error = av_frame_get_buffer(_image_frame, 0);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
_video_frame = av_frame_alloc();
ERR_FAIL_NULL_V_MSG(_video_frame, FAILED, "failed to create video frame");
_video_frame->width = _video_context->width;
_video_frame->height = _video_context->height;
_video_frame->format = _video_context->pix_fmt;
_video_frame->sample_aspect_ratio = _video_context->sample_aspect_ratio;
error = av_frame_get_buffer(_video_frame, 0);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
_sws_context = sws_alloc_context();
ERR_FAIL_NULL_V_MSG(_sws_context, FAILED, "failed to allocate libswscale context");
error = sws_frame_setup(_sws_context, _video_frame, _image_frame);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
DEV_ASSERT(_audio_context->sample_rate % p_fps == 0);
_raw_audio_frame = av_frame_alloc();
ERR_FAIL_NULL_V_MSG(_raw_audio_frame, FAILED, "failed to create raw audio frame");
_raw_audio_frame->nb_samples = _audio_context->sample_rate / p_fps;
_raw_audio_frame->format = AV_SAMPLE_FMT_S32;
_raw_audio_frame->sample_rate = _audio_context->sample_rate;
error = av_channel_layout_copy(&_raw_audio_frame->ch_layout, &_audio_context->ch_layout);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
error = av_frame_get_buffer(_raw_audio_frame, 0);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
_audio_frame = av_frame_alloc();
ERR_FAIL_NULL_V_MSG(_audio_frame, FAILED, "failed to create audio frame");
_audio_frame->nb_samples = _audio_context->frame_size;
_audio_frame->format = _audio_context->sample_fmt;
_audio_frame->sample_rate = _audio_context->sample_rate;
error = av_channel_layout_copy(&_audio_frame->ch_layout, &_audio_context->ch_layout);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
error = av_frame_get_buffer(_audio_frame, 0);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
_swr_context = swr_alloc();
ERR_FAIL_NULL_V_MSG(_swr_context, FAILED, "failed to allocate libswresample context");
error = swr_config_frame(_swr_context, _audio_frame, _raw_audio_frame);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
error = swr_init(_swr_context);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
_packet = av_packet_alloc();
error = avio_open(&_context->pb, p_base_path.utf8().get_data(), AVIO_FLAG_WRITE);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
error = avformat_write_header(_context, nullptr);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
return OK;
#else
return ERR_UNAVAILABLE;
#endif
}
Error FFmpegMovieWriter::_write_frame(const Ref<Image> &p_frame_image, const void *p_audio_frame_block) {
#ifdef FFMPEG_AVAILABLE
ERR_FAIL_COND_V(!_write_image(p_frame_image), FAILED);
ERR_FAIL_COND_V(!_write_audio(p_audio_frame_block), FAILED);
return OK;
#else
return ERR_UNAVAILABLE;
#endif
}
void FFmpegMovieWriter::_write_end() {
#ifdef FFMPEG_AVAILABLE
int error = avcodec_send_frame(_video_context, nullptr);
ERR_FAIL_COND_MSG(error < 0, av_err2str(error));
ERR_FAIL_COND(!_write_packets(_video_context, _video_stream));
// check for any remaining samples at the end of the stream
if (swr_get_delay(_swr_context, _audio_frame->sample_rate) > 0) {
error = av_frame_make_writable(_audio_frame);
ERR_FAIL_COND_MSG(error < 0, av_err2str(error));
error = swr_convert_frame(_swr_context, _audio_frame, nullptr);
ERR_FAIL_COND_MSG(error < 0, av_err2str(error));
_audio_frame->pts = _audio_pts;
error = avcodec_send_frame(_audio_context, _audio_frame);
ERR_FAIL_COND_MSG(error < 0, av_err2str(error));
}
error = avcodec_send_frame(_audio_context, nullptr);
ERR_FAIL_COND_MSG(error < 0, av_err2str(error));
ERR_FAIL_COND(!_write_packets(_audio_context, _audio_stream));
av_write_trailer(_context);
avio_closep(&_context->pb);
av_packet_free(&_packet);
av_frame_free(&_raw_audio_frame);
av_frame_free(&_audio_frame);
av_frame_free(&_video_frame);
av_frame_free(&_image_frame);
swr_free(&_swr_context);
sws_free_context(&_sws_context);
avcodec_free_context(&_audio_context);
avcodec_free_context(&_video_context);
avformat_free_context(_context);
#endif
}
#ifdef FFMPEG_AVAILABLE
bool FFmpegMovieWriter::_write_packets(AVCodecContext *p_context, AVStream *p_stream) {
while (avcodec_receive_packet(p_context, _packet) == 0) {
av_packet_rescale_ts(_packet, p_context->time_base, p_stream->time_base);
_packet->stream_index = p_stream->index;
if (p_context->pix_fmt != AV_PIX_FMT_NONE) {
__builtin_debugtrap();
}
int error = av_interleaved_write_frame(_context, _packet);
CRASH_COND(error < 0);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
}
return true;
}
bool FFmpegMovieWriter::_write_image(const Ref<Image> &p_frame_image) {
DEV_ASSERT(p_frame_image->get_format() == Image::FORMAT_RGBA8);
DEV_ASSERT(p_frame_image->get_width() == _image_frame->width);
DEV_ASSERT(p_frame_image->get_height() == _image_frame->height);
int error = av_frame_make_writable(_image_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
memcpy(_image_frame->data[0], p_frame_image->get_data().ptr(), p_frame_image->get_data_size());
error = av_frame_make_writable(_video_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
error = sws_scale_frame(_sws_context, _video_frame, _image_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
_video_frame->pts = _video_pts;
_video_pts++;
error = avcodec_send_frame(_video_context, _video_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
return _write_packets(_video_context, _video_stream);
}
bool FFmpegMovieWriter::_write_audio(const void *p_audio_frame_block) {
int error = av_frame_make_writable(_raw_audio_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
memcpy(_raw_audio_frame->data[0], p_audio_frame_block, _raw_audio_frame->nb_samples * sizeof(int32_t));
error = swr_convert_frame(_swr_context, nullptr, _raw_audio_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
while (swr_get_delay(_swr_context, _audio_frame->sample_rate) >= _audio_frame->nb_samples) {
error = av_frame_make_writable(_audio_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
error = swr_convert_frame(_swr_context, _audio_frame, nullptr);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
_audio_frame->pts = _audio_pts;
_audio_pts += _audio_frame->nb_samples;
error = avcodec_send_frame(_audio_context, _audio_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
}
return _write_packets(_audio_context, _audio_stream);
}
#endif -
CW: C++
#include "util/ffmpeg_movie_writer.h"
#include <godot_cpp/classes/image.hpp>
#ifdef FFMPEG_AVAILABLE
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswresample/swresample.h>
#include <libswscale/swscale.h>
}
#endif
void FFmpegMovieWriter::_bind_methods() {
}
uint32_t FFmpegMovieWriter::_get_audio_mix_rate() const {
return 48000;
}
AudioServer::SpeakerMode FFmpegMovieWriter::_get_audio_speaker_mode() const {
return AudioServer::SPEAKER_MODE_STEREO;
}
bool FFmpegMovieWriter::_handles_file(const String &p_path) const {
return p_path.get_extension().to_lower() == "mkv";
}
PackedStringArray FFmpegMovieWriter::_get_supported_extensions() const {
return { "mkv" };
}
Error FFmpegMovieWriter::_write_begin(const Vector2i &p_movie_size, uint32_t p_fps, const String &p_base_path) {
#ifdef FFMPEG_AVAILABLE
int error = avformat_alloc_output_context2(&_context, nullptr, "matroska", p_base_path.utf8().get_data());
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
const AVCodec *video_codec = avcodec_find_encoder(AV_CODEC_ID_AV1);
ERR_FAIL_NULL_V_MSG(video_codec, FAILED, "ffmpeg was not compiled with AV1 support");
_video_context = avcodec_alloc_context3(video_codec);
ERR_FAIL_NULL_V_MSG(_video_context, FAILED, "failed to allocate video context");
_video_context->time_base = av_make_q(1, p_fps);
_video_context->framerate = av_make_q(p_fps, 1);
_video_context->width = p_movie_size.x;
_video_context->height = p_movie_size.y;
_video_context->sample_aspect_ratio = av_make_q(1, 1);
_video_context->pix_fmt = AV_PIX_FMT_YUV420P;
AVDictionary *video_options = nullptr;
av_dict_set_int(&video_options, "crf", 30, 0);
error = avcodec_open2(_video_context, video_codec, &video_options);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
av_dict_free(&video_options);
_video_stream = avformat_new_stream(_context, video_codec);
ERR_FAIL_NULL_V_MSG(_video_stream, FAILED, "failed to create video stream");
error = avcodec_parameters_from_context(_video_stream->codecpar, _video_context);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
const AVCodec *audio_codec = avcodec_find_encoder(AV_CODEC_ID_OPUS);
ERR_FAIL_NULL_V_MSG(audio_codec, FAILED, "ffmpeg was not compiled with Opus support");
_audio_context = avcodec_alloc_context3(audio_codec);
ERR_FAIL_NULL_V_MSG(_audio_context, FAILED, "failed to allocate audio context");
_audio_context->bit_rate = 96000;
_audio_context->time_base = av_make_q(1, 48000);
_audio_context->sample_rate = 48000;
_audio_context->sample_fmt = AV_SAMPLE_FMT_S16;
_audio_context->ch_layout = AV_CHANNEL_LAYOUT_STEREO;
error = avcodec_open2(_audio_context, audio_codec, nullptr);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
_audio_stream = avformat_new_stream(_context, audio_codec);
ERR_FAIL_NULL_V_MSG(_audio_stream, FAILED, "failed to create audio stream");
error = avcodec_parameters_from_context(_audio_stream->codecpar, _audio_context);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
_image_frame = av_frame_alloc();
ERR_FAIL_NULL_V_MSG(_image_frame, FAILED, "failed to create image frame");
_image_frame->width = p_movie_size.x;
_image_frame->height = p_movie_size.y;
_image_frame->format = AV_PIX_FMT_RGBA;
_image_frame->sample_aspect_ratio = av_make_q(1, 1);
error = av_frame_get_buffer(_image_frame, 0);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
_video_frame = av_frame_alloc();
ERR_FAIL_NULL_V_MSG(_video_frame, FAILED, "failed to create video frame");
_video_frame->width = _video_context->width;
_video_frame->height = _video_context->height;
_video_frame->format = _video_context->pix_fmt;
_video_frame->sample_aspect_ratio = _video_context->sample_aspect_ratio;
error = av_frame_get_buffer(_video_frame, 0);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
_sws_context = sws_alloc_context();
ERR_FAIL_NULL_V_MSG(_sws_context, FAILED, "failed to allocate libswscale context");
error = sws_frame_setup(_sws_context, _video_frame, _image_frame);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
DEV_ASSERT(_audio_context->sample_rate % p_fps == 0);
_raw_audio_frame = av_frame_alloc();
ERR_FAIL_NULL_V_MSG(_raw_audio_frame, FAILED, "failed to create raw audio frame");
_raw_audio_frame->nb_samples = _audio_context->sample_rate / p_fps;
_raw_audio_frame->format = AV_SAMPLE_FMT_S32;
_raw_audio_frame->sample_rate = _audio_context->sample_rate;
error = av_channel_layout_copy(&_raw_audio_frame->ch_layout, &_audio_context->ch_layout);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
error = av_frame_get_buffer(_raw_audio_frame, 0);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
_audio_frame = av_frame_alloc();
ERR_FAIL_NULL_V_MSG(_audio_frame, FAILED, "failed to create audio frame");
_audio_frame->nb_samples = _audio_context->frame_size;
_audio_frame->format = _audio_context->sample_fmt;
_audio_frame->sample_rate = _audio_context->sample_rate;
error = av_channel_layout_copy(&_audio_frame->ch_layout, &_audio_context->ch_layout);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
error = av_frame_get_buffer(_audio_frame, 0);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
_swr_context = swr_alloc();
ERR_FAIL_NULL_V_MSG(_swr_context, FAILED, "failed to allocate libswresample context");
error = swr_config_frame(_swr_context, _audio_frame, _raw_audio_frame);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
error = swr_init(_swr_context);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
_packet = av_packet_alloc();
error = avio_open(&_context->pb, p_base_path.utf8().get_data(), AVIO_FLAG_WRITE);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
error = avformat_write_header(_context, nullptr);
ERR_FAIL_COND_V_MSG(error < 0, FAILED, av_err2str(error));
return OK;
#else
return ERR_UNAVAILABLE;
#endif
}
Error FFmpegMovieWriter::_write_frame(const Ref<Image> &p_frame_image, const void *p_audio_frame_block) {
#ifdef FFMPEG_AVAILABLE
ERR_FAIL_COND_V(!_write_image(p_frame_image), FAILED);
ERR_FAIL_COND_V(!_write_audio(p_audio_frame_block), FAILED);
return OK;
#else
return ERR_UNAVAILABLE;
#endif
}
void FFmpegMovieWriter::_write_end() {
#ifdef FFMPEG_AVAILABLE
int error = avcodec_send_frame(_video_context, nullptr);
ERR_FAIL_COND_MSG(error < 0, av_err2str(error));
ERR_FAIL_COND(!_write_packets(_video_context, _video_stream));
// check for any remaining samples at the end of the stream
if (swr_get_delay(_swr_context, _audio_frame->sample_rate) > 0) {
error = av_frame_make_writable(_audio_frame);
ERR_FAIL_COND_MSG(error < 0, av_err2str(error));
error = swr_convert_frame(_swr_context, _audio_frame, nullptr);
ERR_FAIL_COND_MSG(error < 0, av_err2str(error));
_audio_frame->pts = _audio_pts;
error = avcodec_send_frame(_audio_context, _audio_frame);
ERR_FAIL_COND_MSG(error < 0, av_err2str(error));
}
error = avcodec_send_frame(_audio_context, nullptr);
ERR_FAIL_COND_MSG(error < 0, av_err2str(error));
ERR_FAIL_COND(!_write_packets(_audio_context, _audio_stream));
av_write_trailer(_context);
avio_closep(&_context->pb);
av_packet_free(&_packet);
av_frame_free(&_raw_audio_frame);
av_frame_free(&_audio_frame);
av_frame_free(&_video_frame);
av_frame_free(&_image_frame);
swr_free(&_swr_context);
sws_free_context(&_sws_context);
avcodec_free_context(&_audio_context);
avcodec_free_context(&_video_context);
avformat_free_context(_context);
#endif
}
#ifdef FFMPEG_AVAILABLE
bool FFmpegMovieWriter::_write_packets(AVCodecContext *p_context, AVStream *p_stream) {
while (avcodec_receive_packet(p_context, _packet) == 0) {
av_packet_rescale_ts(_packet, p_context->time_base, p_stream->time_base);
_packet->stream_index = p_stream->index;
if (p_context->pix_fmt != AV_PIX_FMT_NONE) {
__builtin_debugtrap();
}
int error = av_interleaved_write_frame(_context, _packet);
CRASH_COND(error < 0);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
}
return true;
}
bool FFmpegMovieWriter::_write_image(const Ref<Image> &p_frame_image) {
DEV_ASSERT(p_frame_image->get_format() == Image::FORMAT_RGBA8);
DEV_ASSERT(p_frame_image->get_width() == _image_frame->width);
DEV_ASSERT(p_frame_image->get_height() == _image_frame->height);
int error = av_frame_make_writable(_image_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
memcpy(_image_frame->data[0], p_frame_image->get_data().ptr(), p_frame_image->get_data_size());
error = av_frame_make_writable(_video_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
error = sws_scale_frame(_sws_context, _video_frame, _image_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
_video_frame->pts = _video_pts;
_video_pts++;
error = avcodec_send_frame(_video_context, _video_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
return _write_packets(_video_context, _video_stream);
}
bool FFmpegMovieWriter::_write_audio(const void *p_audio_frame_block) {
int error = av_frame_make_writable(_raw_audio_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
memcpy(_raw_audio_frame->data[0], p_audio_frame_block, _raw_audio_frame->nb_samples * sizeof(int32_t));
error = swr_convert_frame(_swr_context, nullptr, _raw_audio_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
while (swr_get_delay(_swr_context, _audio_frame->sample_rate) >= _audio_frame->nb_samples) {
error = av_frame_make_writable(_audio_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
error = swr_convert_frame(_swr_context, _audio_frame, nullptr);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
_audio_frame->pts = _audio_pts;
_audio_pts += _audio_frame->nb_samples;
error = avcodec_send_frame(_audio_context, _audio_frame);
ERR_FAIL_COND_V_MSG(error < 0, false, av_err2str(error));
}
return _write_packets(_audio_context, _audio_stream);
}
#endif -
ゴミは速やかにゴミ箱へ
Світе, швидко викидай своє сміття у смітник.
Інакше настане червона зима.https://www.pixiv.net/novel/show.php?id=25557218
<>
#trash #immediately #priority #essential #include #people #specific #example #certain #Hanafuda #President #more #Emperor #mercy #currently #impose #death #sentence #Ukraine #world #blind #eye #contamination #touche #result
-
ゴミは速やかにゴミ箱へ
Світе, швидко викидай своє сміття у смітник.
Інакше настане червона зима.https://www.pixiv.net/novel/show.php?id=25557218
<>
#trash #immediately #priority #essential #include #people #specific #example #certain #Hanafuda #President #more #Emperor #mercy #currently #impose #death #sentence #Ukraine #world #blind #eye #contamination #touche #result
-
ゴミは速やかにゴミ箱へ
Світе, швидко викидай своє сміття у смітник.
Інакше настане червона зима.https://www.pixiv.net/novel/show.php?id=25557218
<>
#trash #immediately #priority #essential #include #people #specific #example #certain #Hanafuda #President #more #Emperor #mercy #currently #impose #death #sentence #Ukraine #world #blind #eye #contamination #touche #result