Skip to content

Commit

Permalink
Basic ability to build with FFmpeg 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
h4tr3d committed Jun 11, 2018
1 parent 0b7e390 commit 99c0c81
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion example/api2-samples/api2-scale-video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int main(int argc, char **argv)
encoder.setPixelFormat(vdec.pixelFormat());
encoder.setTimeBase(Rational{1, 1000});
encoder.setBitRate(vdec.bitRate());
encoder.addFlags(octx.outputFormat().isFlags(AVFMT_GLOBALHEADER) ? CODEC_FLAG_GLOBAL_HEADER : 0);
encoder.addFlags(octx.outputFormat().isFlags(AVFMT_GLOBALHEADER) ? AV_CODEC_FLAG_GLOBAL_HEADER : 0);
ost.setFrameRate(vst.frameRate());
ost.setAverageFrameRate(vst.frameRate()); // try to comment this out and look at the output of ffprobe or mpv
// it'll show 1k fps regardless of the real fps;
Expand Down
4 changes: 3 additions & 1 deletion src/ffmpeg.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ extern "C"

extern "C" {
#include <libavfilter/avfilter.h>
#include <libavfilter/avfiltergraph.h>
#if LIBAVFILTER_VERSION_INT < AV_VERSION_INT(7,0,0)
# include <libavfilter/avfiltergraph.h>
#endif
#include <libavfilter/buffersink.h>
#include <libavfilter/buffersrc.h>
#if LIBAVFILTER_VERSION_INT <= AV_VERSION_INT(2,77,100) // 0.11.1
Expand Down
8 changes: 4 additions & 4 deletions src/packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ Packet::Packet(const uint8_t *data, size_t size, bool doAllign)
m_raw.size = size;
if (doAllign)
{
m_raw.data = reinterpret_cast<uint8_t*>(av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE));
std::fill_n(m_raw.data + m_raw.size, FF_INPUT_BUFFER_PADDING_SIZE, '\0');
m_raw.data = reinterpret_cast<uint8_t*>(av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE));
std::fill_n(m_raw.data + m_raw.size, AV_INPUT_BUFFER_PADDING_SIZE, '\0');
}
else
m_raw.data = reinterpret_cast<uint8_t*>(av_malloc(size));
Expand Down Expand Up @@ -112,10 +112,10 @@ bool Packet::setData(const uint8_t *newData, size_t size, OptionalErrorCode ec)
av_buffer_unref(&m_raw.buf);
else
av_freep(&m_raw.data);
m_raw.data = reinterpret_cast<uint8_t*>(av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE));
m_raw.data = reinterpret_cast<uint8_t*>(av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE));
m_raw.size = size;

std::fill_n(m_raw.data + m_raw.size, FF_INPUT_BUFFER_PADDING_SIZE, '\0'); // set padding memory to zero
std::fill_n(m_raw.data + m_raw.size, AV_INPUT_BUFFER_PADDING_SIZE, '\0'); // set padding memory to zero
m_raw.buf = av_buffer_create(m_raw.data, m_raw.size, av_buffer_default_free, nullptr, 0);
if (!m_raw.buf) {
throws_if(ec, ENOMEM, system_category());
Expand Down

0 comments on commit 99c0c81

Please sign in to comment.