diff --git a/src/Frame.cpp b/src/Frame.cpp index 9381560f2..914920a84 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Media play library based on Qt and FFmpeg - Copyright (C) 2012-2014 Wang Bin + Copyright (C) 2012-2015 Wang Bin * This file is part of QtAV @@ -103,12 +103,13 @@ void Frame::setBits(uchar *b, int plane) void Frame::setBits(const QVector &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[]) @@ -130,12 +131,13 @@ void Frame::setBytesPerLine(int lineSize, int plane) void Frame::setBytesPerLine(const QVector &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[]) diff --git a/src/QtAV/Frame.h b/src/QtAV/Frame.h index 588de7a7c..8e392829f 100644 --- a/src/QtAV/Frame.h +++ b/src/QtAV/Frame.h @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Media play library based on Qt and FFmpeg - Copyright (C) 2012-2014 Wang Bin + Copyright (C) 2012-2015 Wang Bin * This file is part of QtAV @@ -70,7 +70,8 @@ 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 */ @@ -78,9 +79,9 @@ class Q_AV_EXPORT Frame void setBits(uchar *b, int plane = 0); void setBits(const QVector& 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& lineSize);