Skip to content
Snippets Groups Projects
Commit 65b75a3a authored by Philippe Gorley's avatar Philippe Gorley
Browse files

debug: fix wav writing

AVFrame.linesize may contain some padding, use AVFrame.nb_samples
instead.

Change-Id: I5e46e89ac102b8dfd939c9ccbc3f51e73d995c6e
parent 3352b741
No related branches found
No related tags found
No related merge requests found
...@@ -99,14 +99,15 @@ public: ...@@ -99,14 +99,15 @@ public:
AVSampleFormat fmt = (AVSampleFormat)frame->format; AVSampleFormat fmt = (AVSampleFormat)frame->format;
int channels = frame->channels; int channels = frame->channels;
int depth = av_get_bytes_per_sample(fmt); int depth = av_get_bytes_per_sample(fmt);
int linesize = frame->linesize[0];
int planar = av_sample_fmt_is_planar(fmt); int planar = av_sample_fmt_is_planar(fmt);
int step = (planar ? depth : depth * channels); int step = (planar ? depth : depth * channels);
for (int i = 0; i < linesize; i += step) { for (int i = 0; i < frame->nb_samples; ++i) {
int offset = i * step;
for (int ch = 0; ch < channels; ++ch) { for (int ch = 0; ch < channels; ++ch) {
int c = (planar ? ch : 0); if (planar)
int offset = (planar ? i : i + depth * ch); writeSample(&frame->extended_data[ch][offset], fmt, depth);
writeSample(&frame->extended_data[c][offset], fmt, depth); else
writeSample(&frame->extended_data[0][offset + ch * depth], fmt, depth);
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment