1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 15:45:31 +00:00

Revert "Fix for compiler warnings and deprecated functions usage in videoplayer."

This reverts commit f5589b42ea.

Conflicts:
	apps/openmw/mwrender/videoplayer.cpp
This commit is contained in:
scrawl 2014-10-19 04:05:16 +02:00
parent 681f3fa530
commit de0e0fedff

View file

@ -32,16 +32,6 @@ extern "C"
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include <libswscale/swscale.h> #include <libswscale/swscale.h>
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0)
#define IS_NOTEQ_NOPTS_VAL(x) ((uint64_t)x != AV_NOPTS_VALUE)
#define IS_NOTEQ_NOPTS_VAL_PTR(x) (*(uint64_t*)x != AV_NOPTS_VALUE)
#else
#define IS_NOTEQ_NOPTS_VAL(x) ((int64_t)x != AV_NOPTS_VALUE)
#define IS_NOTEQ_NOPTS_VAL_PTR(x) (*(int64_t*)x != AV_NOPTS_VALUE)
#endif /* LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0) */
#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
@ -229,11 +219,8 @@ void PacketQueue::put(AVPacket *pkt)
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 LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0)
if(pkt1->pkt.destruct == NULL)
#else
if(pkt1->pkt.buf == NULL) if(pkt1->pkt.buf == NULL)
#endif /* LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0) */
{ {
if(av_dup_packet(&pkt1->pkt) < 0) if(av_dup_packet(&pkt1->pkt) < 0)
{ {
@ -438,7 +425,7 @@ class MovieAudioDecoder : public MWSound::Sound_Decoder
return -1; return -1;
/* if update, update the audio clock w/pts */ /* if update, update the audio clock w/pts */
if(IS_NOTEQ_NOPTS_VAL(pkt->pts)) if(pkt->pts != AV_NOPTS_VALUE)
mAudioClock = av_q2d(mAVStream->time_base)*pkt->pts; mAudioClock = av_q2d(mAVStream->time_base)*pkt->pts;
} }
} }
@ -833,22 +820,6 @@ double VideoState::synchronize_video(AVFrame *src_frame, double pts)
* a frame at the time it is allocated. * a frame at the time it is allocated.
*/ */
static uint64_t global_video_pkt_pts = static_cast<uint64_t>(AV_NOPTS_VALUE); static uint64_t global_video_pkt_pts = static_cast<uint64_t>(AV_NOPTS_VALUE);
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0)
static int our_get_buffer(struct AVCodecContext *c, AVFrame *pic)
{
int ret = avcodec_default_get_buffer(c, pic);
uint64_t *pts = (uint64_t*)av_malloc(sizeof(uint64_t));
*pts = global_video_pkt_pts;
pic->opaque = pts;
return ret;
}
static void our_release_buffer(struct AVCodecContext *c, AVFrame *pic)
{
if(pic) av_freep(&pic->opaque);
avcodec_default_release_buffer(c, pic);
}
#else
static int our_get_buffer2(struct AVCodecContext *c, AVFrame *pic, int flags = AV_GET_BUFFER_FLAG_REF) static int our_get_buffer2(struct AVCodecContext *c, AVFrame *pic, int flags = AV_GET_BUFFER_FLAG_REF)
{ {
int ret = avcodec_default_get_buffer2(c, pic, flags); int ret = avcodec_default_get_buffer2(c, pic, flags);
@ -857,7 +828,6 @@ static int our_get_buffer2(struct AVCodecContext *c, AVFrame *pic, int flags = A
pic->opaque = pts; pic->opaque = pts;
return ret; return ret;
} }
#endif /* LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0) */
void VideoState::video_thread_loop(VideoState *self) void VideoState::video_thread_loop(VideoState *self)
{ {
@ -879,9 +849,9 @@ void VideoState::video_thread_loop(VideoState *self)
throw std::runtime_error("Error decoding video frame"); throw std::runtime_error("Error decoding video frame");
double pts = 0; double pts = 0;
if(IS_NOTEQ_NOPTS_VAL(packet->dts)) if(packet->dts != AV_NOPTS_VALUE)
pts = packet->dts; pts = packet->dts;
else if(pFrame->opaque && IS_NOTEQ_NOPTS_VAL_PTR(pFrame->opaque)) else if(pFrame->opaque && *(int64_t*)pFrame->opaque != AV_NOPTS_VALUE)
pts = *(uint64_t*)pFrame->opaque; pts = *(uint64_t*)pFrame->opaque;
pts *= av_q2d((*self->video_st)->time_base); pts *= av_q2d((*self->video_st)->time_base);
@ -982,9 +952,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx)
// Get a pointer to the codec context for the video stream // Get a pointer to the codec context for the video stream
codecCtx = pFormatCtx->streams[stream_index]->codec; codecCtx = pFormatCtx->streams[stream_index]->codec;
codec = avcodec_find_decoder(codecCtx->codec_id); codec = avcodec_find_decoder(codecCtx->codec_id);
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0)
codecCtx->refcounted_frames = 1; codecCtx->refcounted_frames = 1;
#endif /* LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0) */
if(!codec || (avcodec_open2(codecCtx, codec, NULL) < 0)) if(!codec || (avcodec_open2(codecCtx, codec, NULL) < 0))
{ {
fprintf(stderr, "Unsupported codec!\n"); fprintf(stderr, "Unsupported codec!\n");
@ -1010,12 +978,8 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx)
this->video_st = pFormatCtx->streams + stream_index; this->video_st = pFormatCtx->streams + stream_index;
this->frame_last_delay = 40e-3; this->frame_last_delay = 40e-3;
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0)
codecCtx->get_buffer = our_get_buffer;
codecCtx->release_buffer = our_release_buffer;
#else
codecCtx->get_buffer2 = our_get_buffer2; codecCtx->get_buffer2 = our_get_buffer2;
#endif /* LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0) */
this->video_thread = boost::thread(video_thread_loop, this); this->video_thread = boost::thread(video_thread_loop, this);
this->refresh_thread = boost::thread(video_refresh, this); this->refresh_thread = boost::thread(video_refresh, this);
break; break;