Skip to content

Commit

Permalink
Add function to prepend another AudioFrame to an AudioFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFelix committed Oct 13, 2017
1 parent dff0967 commit b4b21a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/AudioFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,24 @@ AudioFrame AudioFrame::mid(int pos, int len) const
return f;
}

void AudioFrame::prepend(AudioFrame &other)
{
Q_D(AudioFrame);

if (d->format != other.format()) {
qWarning() << "To prepend a frame it must have the same audio format";
return;
}

d->data.prepend(other.data());
d->samples_per_ch += other.samplesPerChannel();
d->timestamp = other.timestamp();

for (int i = 0; i < planeCount(); i++) {
d->line_sizes[i] += other.bytesPerLine(i);
}
}

AudioFormat AudioFrame::format() const
{
return d_func()->format;
Expand Down
1 change: 1 addition & 0 deletions src/QtAV/AudioFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Q_AV_EXPORT AudioFrame : public Frame
*/
AudioFrame clone() const;
AudioFrame mid(int pos, int len = -1) const;
void prepend(AudioFrame &other);
AudioFormat format() const;
void setSamplesPerChannel(int samples);
// may change after resampling
Expand Down

0 comments on commit b4b21a8

Please sign in to comment.