Skip to content

Commit

Permalink
introduce channelCount for Audio/VideoFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Jun 29, 2014
1 parent c535935 commit 9838304
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/AudioFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ AudioFrame::~AudioFrame()
{
}

int AudioFrame::channelCount() const
{
Q_D(const AudioFrame);
if (!d->format.isValid())
return 0;
return d->format.channels();
}

AudioFrame AudioFrame::clone() const
{
Q_D(const AudioFrame);
Expand Down
4 changes: 4 additions & 0 deletions src/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ int Frame::planeCount() const
return d->planes.size();
}

int Frame::channelCount() const
{
return planeCount();
}

/*!
Returns any extra metadata associated with this frame.
Expand Down
1 change: 1 addition & 0 deletions src/QtAV/AudioFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Q_AV_EXPORT AudioFrame : public Frame

AudioFrame &operator =(const AudioFrame &other);

virtual int channelCount() const;
/*!
* Deep copy. If you want to copy data from somewhere, knowing the format, width and height,
* then you can use clone().
Expand Down
9 changes: 8 additions & 1 deletion src/QtAV/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,21 @@ class Q_AV_EXPORT Frame
// allocate memory with given format and other information
virtual int allocate();
/*!
* \brief bytesPerLine
* \brief planeCount
* a decoded frame can be packed and planar. packed format has only 1 plane, while planar
* format has more than 1 plane. For audio, the number plane equals channel count. For
* video, rgb is 1 plane, yuv420p is 3 plane, p means planar
* \param plane default is the first plane
* \return
*/
int planeCount() const;
/*!
* \brief channelCount
* for audio, channel count equals plane count
* for video, channels >= planes
* \return
*/
virtual int channelCount() const;
/*!
* \brief bytesPerLine
* For video, it's size of each picture line. For audio, it's the whole size of plane
Expand Down
1 change: 1 addition & 0 deletions src/QtAV/VideoFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Q_AV_EXPORT VideoFrame : public Frame

VideoFrame &operator =(const VideoFrame &other);

virtual int channelCount() const;
/*!
* Deep copy. Given the format, width and height, plane addresses and line sizes.
*/
Expand Down
8 changes: 8 additions & 0 deletions src/VideoFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ VideoFrame::~VideoFrame()
{
}

int VideoFrame::channelCount() const
{
Q_D(const VideoFrame);
if (!d->format.isValid())
return 0;
return d->format.channels();
}

VideoFrame VideoFrame::clone() const
{
Q_D(const VideoFrame);
Expand Down

0 comments on commit 9838304

Please sign in to comment.