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.
master
jp9000 2015-07-03 17:18:08 -07:00
parent 6f68d9eb97
commit d1e9b9d66a
2 changed files with 3 additions and 3 deletions

View File

@ -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;

View File

@ -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;