Skip to content

Commit

Permalink
VideoFrame.init should be private
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Feb 23, 2014
1 parent 208c0d6 commit be8bec0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
11 changes: 6 additions & 5 deletions src/QtAV/VideoFrame.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) 2013 Wang Bin <[email protected]>
Copyright (C) 2012-2014 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -63,10 +63,6 @@ class Q_AV_EXPORT VideoFrame : public Frame
int pixelFormatFFmpeg() const;

bool isValid() const;
/*
* call this only when setBytesPerLine() and setBits() will not be called
*/
void init();

QSize size() const;
//int width(int plane = 0) const?
Expand Down Expand Up @@ -94,6 +90,11 @@ class Q_AV_EXPORT VideoFrame : public Frame
return -1 if no texture, not uploaded
*/
int texture(int plane = 0) const;
private:
/*
* call this only when setBytesPerLine() and setBits() will not be called
*/
void init();
};

} //namespace QtAV
Expand Down
26 changes: 13 additions & 13 deletions src/VideoFrame.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) 2013 Wang Bin <[email protected]>
Copyright (C) 2012-2014 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -242,18 +242,6 @@ bool VideoFrame::isValid() const
return d->width > 0 && d->height > 0 && d->format.isValid(); //data not empty?
}

void VideoFrame::init()
{
Q_D(VideoFrame);
AVPicture picture;
AVPixelFormat fff = (AVPixelFormat)d->format.pixelFormatFFmpeg();
//int bytes = avpicture_get_size(fff, width(), height());
//d->data.resize(bytes);
avpicture_fill(&picture, reinterpret_cast<uint8_t*>(d->data.data()), fff, width(), height());
setBits(picture.data);
setBytesPerLine(picture.linesize);
}

QSize VideoFrame::size() const
{
Q_D(const VideoFrame);
Expand Down Expand Up @@ -337,4 +325,16 @@ int VideoFrame::texture(int plane) const
return d->textures[plane];
}

void VideoFrame::init()
{
Q_D(VideoFrame);
AVPicture picture;
AVPixelFormat fff = (AVPixelFormat)d->format.pixelFormatFFmpeg();
//int bytes = avpicture_get_size(fff, width(), height());
//d->data.resize(bytes);
avpicture_fill(&picture, reinterpret_cast<uint8_t*>(d->data.data()), fff, width(), height());
setBits(picture.data);
setBytesPerLine(picture.linesize);
}

} //namespace QtAV

0 comments on commit be8bec0

Please sign in to comment.