mirror of
https://github.com/mpv-player/mpv
synced 2025-02-02 05:01:56 +00:00
audio: change bps format to int64_t
Same as ffmpeg uses. Such big values does not make sense probably, but let's not overflow values and maybe one day it will be useful. Fixes signed integer overflow.
This commit is contained in:
parent
c1d5f0e9c8
commit
0d18c1bfdc
@ -600,7 +600,7 @@ bool mp_aframe_set_silence(struct mp_aframe *f, int offset, int samples)
|
||||
bool mp_aframe_reverse(struct mp_aframe *f)
|
||||
{
|
||||
int format = mp_aframe_get_format(f);
|
||||
size_t bps = af_fmt_to_bytes(format);
|
||||
int bps = af_fmt_to_bytes(format);
|
||||
if (!af_fmt_is_pcm(format) || bps > 16)
|
||||
return false;
|
||||
|
||||
|
@ -241,7 +241,7 @@ static struct ao *ao_init(bool probing, struct mpv_global *global,
|
||||
} else {
|
||||
ao->sstride *= ao->channels.num;
|
||||
}
|
||||
ao->bps = ao->samplerate * ao->sstride;
|
||||
ao->bps = (int64_t)ao->samplerate * ao->sstride;
|
||||
|
||||
if (ao->device_buffer <= 0 && ao->driver->write) {
|
||||
MP_ERR(ao, "Device buffer size not set.\n");
|
||||
|
@ -86,7 +86,7 @@ static void write_wave_header(struct ao *ao, FILE *fp, uint64_t data_length)
|
||||
fput16le(WAV_ID_FORMAT_EXTENSIBLE, fp);
|
||||
fput16le(ao->channels.num, fp);
|
||||
fput32le(ao->samplerate, fp);
|
||||
fput32le(ao->bps, fp);
|
||||
fput32le(MPCLAMP(ao->bps, 0, UINT32_MAX), fp);
|
||||
fput16le(ao->channels.num * (bits / 8), fp);
|
||||
fput16le(bits, fp);
|
||||
|
||||
@ -145,7 +145,7 @@ static int init(struct ao *ao)
|
||||
if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels))
|
||||
return -1;
|
||||
|
||||
ao->bps = ao->channels.num * ao->samplerate * af_fmt_to_bytes(ao->format);
|
||||
ao->bps = ao->channels.num * (int64_t)ao->samplerate * af_fmt_to_bytes(ao->format);
|
||||
|
||||
MP_INFO(ao, "File: %s (%s)\nPCM: Samplerate: %d Hz Channels: %d Format: %s\n",
|
||||
outputfilename,
|
||||
|
@ -28,7 +28,7 @@ struct ao {
|
||||
int samplerate;
|
||||
struct mp_chmap channels;
|
||||
int format; // one of AF_FORMAT_...
|
||||
int bps; // bytes per second (per plane)
|
||||
int64_t bps; // bytes per second (per plane)
|
||||
int sstride; // size of a sample on each plane
|
||||
// (format_size*num_channels/num_planes)
|
||||
int num_planes;
|
||||
|
Loading…
Reference in New Issue
Block a user