提交 d1e9b9d6 编写于 作者: J jp9000

obs-ffmpeg: Fix potential integer overflows

This particularly affected audio encoding, audio encoding previously
would count samples and use it to create an encoding timestamp, but
because I was using a standard integer (which is 32bit by default on
x86), it would max out at about 0x7FFFFFFF samples, which is about 12
hours of samples at 48000 sample rate.  After that, it would start going
into negative territory (overflowing).  By changing it to int64_t, it
will make it so that audio at 48000 samples per second would only be
able to overflow after about..  6.09 million years.  In other words,
this should fix the issue for good.
上级 6f68d9eb
......@@ -33,7 +33,7 @@ struct aac_encoder {
uint8_t *samples[MAX_AV_PLANES];
AVFrame *aframe;
int total_samples;
int64_t total_samples;
DARRAY(uint8_t) packet_buffer;
......
......@@ -57,13 +57,14 @@ struct ffmpeg_data {
AVFormatContext *output;
struct SwsContext *swscale;
int64_t total_frames;
AVPicture dst_picture;
AVFrame *vframe;
int frame_size;
int total_frames;
uint64_t start_timestamp;
int64_t total_samples;
uint32_t audio_samplerate;
enum audio_format audio_format;
size_t audio_planes;
......@@ -71,7 +72,6 @@ struct ffmpeg_data {
struct circlebuf excess_frames[MAX_AV_PLANES];
uint8_t *samples[MAX_AV_PLANES];
AVFrame *aframe;
int total_samples;
struct ffmpeg_cfg config;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册