summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-21 10:03:23 +0100
committerwm4 <wm4@nowhere>2014-11-21 10:09:25 +0100
commitc6c46f5aa7045c365e2cbb6cc251319068744067 (patch)
tree1729dc7397badf08627fa89d15b1ade767b60310 /audio
parentc01a62efbc33cee9ac032d524c2227e35eb29a01 (diff)
downloadmpv-c6c46f5aa7045c365e2cbb6cc251319068744067.tar.bz2
mpv-c6c46f5aa7045c365e2cbb6cc251319068744067.tar.xz
ao_lavc: fix setting up AVFrame pointers
The caller set up the "start" pointer array using the number of planes, the encode() function used the number of channels. This copied uninitialized values for packed formats, which makes Coverity warn.
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_lavc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c
index 5f31ef3885..2405b2213a 100644
--- a/audio/out/ao_lavc.c
+++ b/audio/out/ao_lavc.c
@@ -242,8 +242,9 @@ static int encode(struct ao *ao, double apts, void **data)
frame->format = af_to_avformat(ao->format);
frame->nb_samples = ac->aframesize;
- assert(ao->channels.num <= AV_NUM_DATA_POINTERS);
- for (int n = 0; n < ao->channels.num; n++)
+ size_t num_planes = af_fmt_is_planar(ao->format) ? ao->channels.num : 1;
+ assert(num_planes <= AV_NUM_DATA_POINTERS);
+ for (int n = 0; n < num_planes; n++)
frame->extended_data[n] = data[n];
frame->linesize[0] = frame->nb_samples * ao->sstride;
@@ -438,7 +439,7 @@ static int play(struct ao *ao, void **data, int samples, int flags)
outpts += encode_lavc_getoffset(ectx, ac->stream);
while (samples - bufpos >= ac->aframesize) {
- void *start[MP_NUM_CHANNELS];
+ void *start[MP_NUM_CHANNELS] = {0};
for (int n = 0; n < num_planes; n++)
start[n] = (char *)data[n] + bufpos * ao->sstride;
encode(ao, outpts + bufpos / (double) ao->samplerate, start);