Skip to content

Commit

Permalink
frame always copy valid values from given pitch/stride array
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Jan 8, 2015
1 parent 23f5a8b commit 41583db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
20 changes: 11 additions & 9 deletions src/Frame.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012-2014 Wang Bin <[email protected]>
Copyright (C) 2012-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -103,12 +103,13 @@ void Frame::setBits(uchar *b, int plane)

void Frame::setBits(const QVector<uchar *> &b)
{
if (b.size() > planeCount()) {
qWarning("Invalid plane size! Valid range is [0, %d), current is %d", planeCount(), b.size());
return;
}
Q_D(Frame);
const int nb_planes = planeCount();
d->planes = b;
if (d->planes.size() > nb_planes) {
d->planes.reserve(nb_planes);
d->planes.resize(nb_planes);
}
}

void Frame::setBits(quint8 *slice[])
Expand All @@ -130,12 +131,13 @@ void Frame::setBytesPerLine(int lineSize, int plane)

void Frame::setBytesPerLine(const QVector<int> &lineSize)
{
if (lineSize.size() > planeCount()) {
qWarning("Invalid plane size! Valid range is [0, %d), current is %d", planeCount(), lineSize.size());
return;
}
Q_D(Frame);
const int nb_planes = planeCount();
d->line_sizes = lineSize;
if (d->line_sizes.size() > nb_planes) {
d->line_sizes.reserve(nb_planes);
d->line_sizes.resize(nb_planes);
}
}

void Frame::setBytesPerLine(int stride[])
Expand Down
11 changes: 6 additions & 5 deletions src/QtAV/Frame.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012-2014 Wang Bin <[email protected]>
Copyright (C) 2012-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -70,17 +70,18 @@ class Q_AV_EXPORT Frame
uchar* bits(int plane = 0);
const uchar *bits(int plane = 0) const;
/*!
* \brief setBits set slice from FFmpeg
* \brief setBits
* does nothing if plane is invalid. if given array size is greater than planeCount(), only planeCount() elements is used
* \param b slice
* \param plane color/audio channel
*/
// TODO: const?
void setBits(uchar *b, int plane = 0);
void setBits(const QVector<uchar*>& b);
void setBits(quint8 *slice[]);
/*
* It's used now until I complete all pixel formats in QtAV.
* set strides from FFmpeg. 4 channels at most for video
/*!
* \brief setBytesPerLine
* does nothing if plane is invalid. if given array size is greater than planeCount(), only planeCount() elements is used
*/
void setBytesPerLine(int lineSize, int plane = 0);
void setBytesPerLine(const QVector<int>& lineSize);
Expand Down

0 comments on commit 41583db

Please sign in to comment.