mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 00:36:46 +00:00
Merge branch 'openmw-37'
This commit is contained in:
commit
c312162b57
11 changed files with 21 additions and 282 deletions
|
@ -223,6 +223,7 @@
|
||||||
Task #2730: Replace hardcoded column numbers in SimpleDialogueSubView/DialogueSubView
|
Task #2730: Replace hardcoded column numbers in SimpleDialogueSubView/DialogueSubView
|
||||||
Task #2750: Bullet shape instancing optimization
|
Task #2750: Bullet shape instancing optimization
|
||||||
Task #2793: Replace grid size setting with half grid size setting
|
Task #2793: Replace grid size setting with half grid size setting
|
||||||
|
Task #3003: Support FFMPEG 2.9 (Debian request)
|
||||||
|
|
||||||
0.36.1
|
0.36.1
|
||||||
------
|
------
|
||||||
|
|
|
@ -14,7 +14,7 @@ echo "yes" | sudo apt-add-repository ppa:boost-latest/ppa
|
||||||
sudo apt-get update -qq
|
sudo apt-get update -qq
|
||||||
sudo apt-get install -qq libgtest-dev google-mock
|
sudo apt-get install -qq libgtest-dev google-mock
|
||||||
sudo apt-get install -qq libboost-filesystem1.55-dev libboost-program-options1.55-dev libboost-system1.55-dev libboost-thread1.55-dev
|
sudo apt-get install -qq libboost-filesystem1.55-dev libboost-program-options1.55-dev libboost-system1.55-dev libboost-thread1.55-dev
|
||||||
sudo apt-get install -qq libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libavresample-dev
|
sudo apt-get install -qq ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev
|
||||||
sudo apt-get install -qq libbullet-dev libopenscenegraph-dev libmygui-dev libsdl2-dev libunshield-dev libtinyxml-dev libopenal-dev libqt4-dev
|
sudo apt-get install -qq libbullet-dev libopenscenegraph-dev libmygui-dev libsdl2-dev libunshield-dev libtinyxml-dev libopenal-dev libqt4-dev
|
||||||
sudo apt-get install -qq cmake-data #workaround for broken osgqt cmake script in ubuntu 12.04
|
sudo apt-get install -qq cmake-data #workaround for broken osgqt cmake script in ubuntu 12.04
|
||||||
if [ "${ANALYZE}" ]; then sudo apt-get install -qq clang-3.6; fi
|
if [ "${ANALYZE}" ]; then sudo apt-get install -qq clang-3.6; fi
|
||||||
|
|
|
@ -107,22 +107,11 @@ unset(FFMPEG_LIBRARIES CACHE)
|
||||||
|
|
||||||
find_package(FFmpeg REQUIRED)
|
find_package(FFmpeg REQUIRED)
|
||||||
|
|
||||||
set (FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${SWSCALE_LIBRARY})
|
set (FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${SWSCALE_LIBRARY} ${SWRESAMPLE_LIBRARIES})
|
||||||
|
|
||||||
if ( NOT AVCODEC_FOUND OR NOT AVFORMAT_FOUND OR NOT AVUTIL_FOUND OR NOT SWSCALE_FOUND )
|
if ( NOT AVCODEC_FOUND OR NOT AVFORMAT_FOUND OR NOT AVUTIL_FOUND OR NOT SWSCALE_FOUND OR NOT SWRESAMPLE_FOUND)
|
||||||
message(FATAL_ERROR "FFmpeg component required, but not found!")
|
message(FATAL_ERROR "FFmpeg component required, but not found!")
|
||||||
endif()
|
endif()
|
||||||
set(SOUND_INPUT_INCLUDES ${FFMPEG_INCLUDE_DIRS})
|
|
||||||
if( SWRESAMPLE_FOUND )
|
|
||||||
add_definitions(-DHAVE_LIBSWRESAMPLE)
|
|
||||||
set (FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${SWRESAMPLE_LIBRARIES})
|
|
||||||
else()
|
|
||||||
if( AVRESAMPLE_FOUND )
|
|
||||||
set (FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${AVRESAMPLE_LIBRARIES})
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Install either libswresample (FFmpeg) or libavresample (Libav).")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
# Required for building the FFmpeg headers
|
# Required for building the FFmpeg headers
|
||||||
add_definitions(-D__STDC_CONSTANT_MACROS)
|
add_definitions(-D__STDC_CONSTANT_MACROS)
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ add_openmw_dir (mwscript
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwsound
|
add_openmw_dir (mwsound
|
||||||
soundmanagerimp openal_output ffmpeg_decoder sound sound_decoder sound_output loudness libavwrapper movieaudiofactory
|
soundmanagerimp openal_output ffmpeg_decoder sound sound_decoder sound_output loudness movieaudiofactory
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwworld
|
add_openmw_dir (mwworld
|
||||||
|
|
|
@ -6,16 +6,6 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#ifndef HAVE_LIBSWRESAMPLE
|
|
||||||
// FIXME: remove this section once libswresample is packaged for Debian
|
|
||||||
int swr_init(AVAudioResampleContext *avr);
|
|
||||||
void swr_free(AVAudioResampleContext **avr);
|
|
||||||
int swr_convert( AVAudioResampleContext *avr, uint8_t** output, int out_samples, const uint8_t** input, int in_samples);
|
|
||||||
AVAudioResampleContext * swr_alloc_set_opts( AVAudioResampleContext *avr, int64_t out_ch_layout, AVSampleFormat out_fmt, int out_rate, int64_t in_ch_layout, AVSampleFormat in_fmt, int in_rate, int o, void* l);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <components/vfs/manager.hpp>
|
#include <components/vfs/manager.hpp>
|
||||||
|
|
||||||
namespace MWSound
|
namespace MWSound
|
||||||
|
|
|
@ -22,13 +22,7 @@ extern "C"
|
||||||
// From version 54.56 binkaudio encoding format changed from S16 to FLTP. See:
|
// From version 54.56 binkaudio encoding format changed from S16 to FLTP. See:
|
||||||
// https://gitorious.org/ffmpeg/ffmpeg/commit/7bfd1766d1c18f07b0a2dd042418a874d49ea60d
|
// https://gitorious.org/ffmpeg/ffmpeg/commit/7bfd1766d1c18f07b0a2dd042418a874d49ea60d
|
||||||
// http://ffmpeg.zeranoe.com/forum/viewtopic.php?f=15&t=872
|
// http://ffmpeg.zeranoe.com/forum/viewtopic.php?f=15&t=872
|
||||||
#ifdef HAVE_LIBSWRESAMPLE
|
|
||||||
#include <libswresample/swresample.h>
|
#include <libswresample/swresample.h>
|
||||||
#else
|
|
||||||
#include <libavresample/avresample.h>
|
|
||||||
#include <libavutil/opt.h>
|
|
||||||
#define SwrContext AVAudioResampleContext
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <components/files/constrainedfilestream.hpp>
|
#include <components/files/constrainedfilestream.hpp>
|
||||||
|
|
|
@ -1,108 +0,0 @@
|
||||||
#ifndef HAVE_LIBSWRESAMPLE
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
// From libavutil version 52.2.0 and onward the declaration of
|
|
||||||
// AV_CH_LAYOUT_* is removed from libavcodec/avcodec.h and moved to
|
|
||||||
// libavutil/channel_layout.h
|
|
||||||
#if AV_VERSION_INT(52, 2, 0) <= AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
|
||||||
LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO)
|
|
||||||
#include <libavutil/channel_layout.h>
|
|
||||||
#endif
|
|
||||||
#include <libavresample/avresample.h>
|
|
||||||
#include <libavutil/opt.h>
|
|
||||||
|
|
||||||
/* FIXME: delete this file once libswresample is packaged for Debian */
|
|
||||||
|
|
||||||
int swr_init(AVAudioResampleContext *avr) { return 1; }
|
|
||||||
|
|
||||||
void swr_free(AVAudioResampleContext **avr) { avresample_free(avr); }
|
|
||||||
|
|
||||||
int swr_convert(
|
|
||||||
AVAudioResampleContext *avr,
|
|
||||||
uint8_t** output,
|
|
||||||
int out_samples,
|
|
||||||
const uint8_t** input,
|
|
||||||
int in_samples)
|
|
||||||
{
|
|
||||||
// FIXME: potential performance hit
|
|
||||||
int out_plane_size = 0;
|
|
||||||
int in_plane_size = 0;
|
|
||||||
return avresample_convert(avr, output, out_plane_size, out_samples,
|
|
||||||
(uint8_t **)input, in_plane_size, in_samples);
|
|
||||||
}
|
|
||||||
|
|
||||||
AVAudioResampleContext * swr_alloc_set_opts(
|
|
||||||
AVAudioResampleContext *avr,
|
|
||||||
int64_t out_ch_layout,
|
|
||||||
AVSampleFormat out_fmt,
|
|
||||||
int out_rate,
|
|
||||||
int64_t in_ch_layout,
|
|
||||||
AVSampleFormat in_fmt,
|
|
||||||
int in_rate,
|
|
||||||
int o,
|
|
||||||
void* l)
|
|
||||||
{
|
|
||||||
avr = avresample_alloc_context();
|
|
||||||
if(!avr)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int res;
|
|
||||||
res = av_opt_set_int(avr, "out_channel_layout", out_ch_layout, 0);
|
|
||||||
if(res < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "av_opt_set_int: out_ch_layout = %d\n", res);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
res = av_opt_set_int(avr, "out_sample_fmt", out_fmt, 0);
|
|
||||||
if(res < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "av_opt_set_int: out_fmt = %d\n", res);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
res = av_opt_set_int(avr, "out_sample_rate", out_rate, 0);
|
|
||||||
if(res < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "av_opt_set_int: out_rate = %d\n", res);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
res = av_opt_set_int(avr, "in_channel_layout", in_ch_layout, 0);
|
|
||||||
if(res < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "av_opt_set_int: in_ch_layout = %d\n", res);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
res = av_opt_set_int(avr, "in_sample_fmt", in_fmt, 0);
|
|
||||||
if(res < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "av_opt_set_int: in_fmt = %d\n", res);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
res = av_opt_set_int(avr, "in_sample_rate", in_rate, 0);
|
|
||||||
if(res < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "av_opt_set_int: in_rate = %d\n", res);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
res = av_opt_set_int(avr, "internal_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);
|
|
||||||
if(res < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "av_opt_set_int: internal_sample_fmt\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(avresample_open(avr) < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "Error opening context\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return avr;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
1
extern/osg-ffmpeg-videoplayer/CMakeLists.txt
vendored
1
extern/osg-ffmpeg-videoplayer/CMakeLists.txt
vendored
|
@ -6,7 +6,6 @@ set(OSG_FFMPEG_VIDEOPLAYER_SOURCE_FILES
|
||||||
videoplayer.cpp
|
videoplayer.cpp
|
||||||
videostate.cpp
|
videostate.cpp
|
||||||
videodefs.hpp
|
videodefs.hpp
|
||||||
libavwrapper.cpp
|
|
||||||
audiodecoder.cpp
|
audiodecoder.cpp
|
||||||
audiofactory.hpp
|
audiofactory.hpp
|
||||||
)
|
)
|
||||||
|
|
12
extern/osg-ffmpeg-videoplayer/audiodecoder.cpp
vendored
12
extern/osg-ffmpeg-videoplayer/audiodecoder.cpp
vendored
|
@ -6,24 +6,12 @@ extern "C"
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
|
|
||||||
#ifdef HAVE_LIBSWRESAMPLE
|
|
||||||
#include <libswresample/swresample.h>
|
#include <libswresample/swresample.h>
|
||||||
#else
|
|
||||||
// FIXME: remove this section once libswresample is packaged for Debian
|
|
||||||
#include <libavresample/avresample.h>
|
|
||||||
#include <libavutil/opt.h>
|
|
||||||
#define SwrContext AVAudioResampleContext
|
|
||||||
int swr_init(AVAudioResampleContext *avr);
|
|
||||||
void swr_free(AVAudioResampleContext **avr);
|
|
||||||
int swr_convert( AVAudioResampleContext *avr, uint8_t** output, int out_samples, const uint8_t** input, int in_samples);
|
|
||||||
AVAudioResampleContext * swr_alloc_set_opts( AVAudioResampleContext *avr, int64_t out_ch_layout, AVSampleFormat out_fmt, int out_rate, int64_t in_ch_layout, AVSampleFormat in_fmt, int in_rate, int o, void* l);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,28,1)
|
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,28,1)
|
||||||
#define av_frame_alloc avcodec_alloc_frame
|
#define av_frame_alloc avcodec_alloc_frame
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "videostate.hpp"
|
#include "videostate.hpp"
|
||||||
|
|
110
extern/osg-ffmpeg-videoplayer/libavwrapper.cpp
vendored
110
extern/osg-ffmpeg-videoplayer/libavwrapper.cpp
vendored
|
@ -1,110 +0,0 @@
|
||||||
// This file is a wrapper around the libavresample library (the API-incompatible swresample replacement in the libav fork of ffmpeg), to make it look like swresample to the user.
|
|
||||||
|
|
||||||
#ifndef HAVE_LIBSWRESAMPLE
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
|
||||||
#include <libavformat/avformat.h>
|
|
||||||
// From libavutil version 52.2.0 and onward the declaration of
|
|
||||||
// AV_CH_LAYOUT_* is removed from libavcodec/avcodec.h and moved to
|
|
||||||
// libavutil/channel_layout.h
|
|
||||||
#if AV_VERSION_INT(52, 2, 0) <= AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
|
||||||
LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO)
|
|
||||||
#include <libavutil/channel_layout.h>
|
|
||||||
#endif
|
|
||||||
#include <libavresample/avresample.h>
|
|
||||||
#include <libavutil/opt.h>
|
|
||||||
|
|
||||||
/* FIXME: delete this file once libswresample is packaged for Debian */
|
|
||||||
|
|
||||||
int swr_init(AVAudioResampleContext *avr) { return 1; }
|
|
||||||
|
|
||||||
void swr_free(AVAudioResampleContext **avr) { avresample_free(avr); }
|
|
||||||
|
|
||||||
int swr_convert(
|
|
||||||
AVAudioResampleContext *avr,
|
|
||||||
uint8_t** output,
|
|
||||||
int out_samples,
|
|
||||||
const uint8_t** input,
|
|
||||||
int in_samples)
|
|
||||||
{
|
|
||||||
// FIXME: potential performance hit
|
|
||||||
int out_plane_size = 0;
|
|
||||||
int in_plane_size = 0;
|
|
||||||
return avresample_convert(avr, output, out_plane_size, out_samples,
|
|
||||||
(uint8_t **)input, in_plane_size, in_samples);
|
|
||||||
}
|
|
||||||
|
|
||||||
AVAudioResampleContext * swr_alloc_set_opts(
|
|
||||||
AVAudioResampleContext *avr,
|
|
||||||
int64_t out_ch_layout,
|
|
||||||
AVSampleFormat out_fmt,
|
|
||||||
int out_rate,
|
|
||||||
int64_t in_ch_layout,
|
|
||||||
AVSampleFormat in_fmt,
|
|
||||||
int in_rate,
|
|
||||||
int o,
|
|
||||||
void* l)
|
|
||||||
{
|
|
||||||
avr = avresample_alloc_context();
|
|
||||||
if(!avr)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int res;
|
|
||||||
res = av_opt_set_int(avr, "out_channel_layout", out_ch_layout, 0);
|
|
||||||
if(res < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "av_opt_set_int: out_ch_layout = %d\n", res);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
res = av_opt_set_int(avr, "out_sample_fmt", out_fmt, 0);
|
|
||||||
if(res < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "av_opt_set_int: out_fmt = %d\n", res);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
res = av_opt_set_int(avr, "out_sample_rate", out_rate, 0);
|
|
||||||
if(res < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "av_opt_set_int: out_rate = %d\n", res);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
res = av_opt_set_int(avr, "in_channel_layout", in_ch_layout, 0);
|
|
||||||
if(res < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "av_opt_set_int: in_ch_layout = %d\n", res);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
res = av_opt_set_int(avr, "in_sample_fmt", in_fmt, 0);
|
|
||||||
if(res < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "av_opt_set_int: in_fmt = %d\n", res);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
res = av_opt_set_int(avr, "in_sample_rate", in_rate, 0);
|
|
||||||
if(res < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "av_opt_set_int: in_rate = %d\n", res);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
res = av_opt_set_int(avr, "internal_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);
|
|
||||||
if(res < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "av_opt_set_int: internal_sample_fmt\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(avresample_open(avr) < 0)
|
|
||||||
{
|
|
||||||
av_log(avr, AV_LOG_ERROR, "Error opening context\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return avr;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
36
extern/osg-ffmpeg-videoplayer/videostate.cpp
vendored
36
extern/osg-ffmpeg-videoplayer/videostate.cpp
vendored
|
@ -85,21 +85,14 @@ void VideoState::setAudioFactory(MovieAudioFactory *factory)
|
||||||
void PacketQueue::put(AVPacket *pkt)
|
void PacketQueue::put(AVPacket *pkt)
|
||||||
{
|
{
|
||||||
AVPacketList *pkt1;
|
AVPacketList *pkt1;
|
||||||
|
if(pkt != &flush_pkt && !pkt->buf && av_dup_packet(pkt) < 0)
|
||||||
|
throw std::runtime_error("Failed to duplicate packet");
|
||||||
|
|
||||||
pkt1 = (AVPacketList*)av_malloc(sizeof(AVPacketList));
|
pkt1 = (AVPacketList*)av_malloc(sizeof(AVPacketList));
|
||||||
if(!pkt1) throw std::bad_alloc();
|
if(!pkt1) throw std::bad_alloc();
|
||||||
pkt1->pkt = *pkt;
|
pkt1->pkt = *pkt;
|
||||||
pkt1->next = NULL;
|
pkt1->next = NULL;
|
||||||
|
|
||||||
if(pkt->data != flush_pkt.data && pkt1->pkt.destruct == NULL)
|
|
||||||
{
|
|
||||||
if(av_dup_packet(&pkt1->pkt) < 0)
|
|
||||||
{
|
|
||||||
av_free(pkt1);
|
|
||||||
throw std::runtime_error("Failed to duplicate packet");
|
|
||||||
}
|
|
||||||
av_free_packet(pkt);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->mutex.lock ();
|
this->mutex.lock ();
|
||||||
|
|
||||||
if(!last_pkt)
|
if(!last_pkt)
|
||||||
|
@ -313,7 +306,7 @@ int VideoState::queue_picture(AVFrame *pFrame, double pts)
|
||||||
int w = (*this->video_st)->codec->width;
|
int w = (*this->video_st)->codec->width;
|
||||||
int h = (*this->video_st)->codec->height;
|
int h = (*this->video_st)->codec->height;
|
||||||
this->sws_context = sws_getContext(w, h, (*this->video_st)->codec->pix_fmt,
|
this->sws_context = sws_getContext(w, h, (*this->video_st)->codec->pix_fmt,
|
||||||
w, h, PIX_FMT_RGBA, SWS_BICUBIC,
|
w, h, AV_PIX_FMT_RGBA, SWS_BICUBIC,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
if(this->sws_context == NULL)
|
if(this->sws_context == NULL)
|
||||||
throw std::runtime_error("Cannot initialize the conversion context!\n");
|
throw std::runtime_error("Cannot initialize the conversion context!\n");
|
||||||
|
@ -354,24 +347,28 @@ double VideoState::synchronize_video(AVFrame *src_frame, double pts)
|
||||||
return pts;
|
return pts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void our_free_buffer(void *opaque, uint8_t *data);
|
||||||
/* These are called whenever we allocate a frame
|
/* These are called whenever we allocate a frame
|
||||||
* buffer. We use this to store the global_pts in
|
* buffer. We use this to store the global_pts in
|
||||||
* a frame at the time it is allocated.
|
* a frame at the time it is allocated.
|
||||||
*/
|
*/
|
||||||
static int64_t global_video_pkt_pts = AV_NOPTS_VALUE;
|
static int64_t global_video_pkt_pts = AV_NOPTS_VALUE;
|
||||||
static int our_get_buffer(struct AVCodecContext *c, AVFrame *pic)
|
static int our_get_buffer(struct AVCodecContext *c, AVFrame *pic, int flags)
|
||||||
{
|
{
|
||||||
int ret = avcodec_default_get_buffer(c, pic);
|
AVBufferRef *ref;
|
||||||
|
int ret = avcodec_default_get_buffer2(c, pic, flags);
|
||||||
int64_t *pts = (int64_t*)av_malloc(sizeof(int64_t));
|
int64_t *pts = (int64_t*)av_malloc(sizeof(int64_t));
|
||||||
*pts = global_video_pkt_pts;
|
*pts = global_video_pkt_pts;
|
||||||
pic->opaque = pts;
|
pic->opaque = pts;
|
||||||
|
ref = av_buffer_create((uint8_t *)pic->opaque, sizeof(int64_t), our_free_buffer, pic->buf[0], flags);
|
||||||
|
pic->buf[0] = ref;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
static void our_release_buffer(struct AVCodecContext *c, AVFrame *pic)
|
static void our_free_buffer(void *opaque, uint8_t *data)
|
||||||
{
|
{
|
||||||
if(pic) av_freep(&pic->opaque);
|
AVBufferRef *ref = (AVBufferRef *)opaque;
|
||||||
avcodec_default_release_buffer(c, pic);
|
av_buffer_unref(&ref);
|
||||||
|
av_free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -384,7 +381,7 @@ void VideoState::video_thread_loop(VideoState *self)
|
||||||
pFrame = av_frame_alloc();
|
pFrame = av_frame_alloc();
|
||||||
|
|
||||||
self->rgbaFrame = av_frame_alloc();
|
self->rgbaFrame = av_frame_alloc();
|
||||||
avpicture_alloc((AVPicture*)self->rgbaFrame, PIX_FMT_RGBA, (*self->video_st)->codec->width, (*self->video_st)->codec->height);
|
avpicture_alloc((AVPicture*)self->rgbaFrame, AV_PIX_FMT_RGBA, (*self->video_st)->codec->width, (*self->video_st)->codec->height);
|
||||||
|
|
||||||
while(self->videoq.get(packet, self) >= 0)
|
while(self->videoq.get(packet, self) >= 0)
|
||||||
{
|
{
|
||||||
|
@ -589,8 +586,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx)
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
this->video_st = pFormatCtx->streams + stream_index;
|
this->video_st = pFormatCtx->streams + stream_index;
|
||||||
|
|
||||||
codecCtx->get_buffer = our_get_buffer;
|
codecCtx->get_buffer2 = our_get_buffer;
|
||||||
codecCtx->release_buffer = our_release_buffer;
|
|
||||||
this->video_thread = boost::thread(video_thread_loop, this);
|
this->video_thread = boost::thread(video_thread_loop, this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue