From de0e0fedff8e52f5976efcab75470a1a24b544a9 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 19 Oct 2014 04:05:16 +0200 Subject: [PATCH] Revert "Fix for compiler warnings and deprecated functions usage in videoplayer." This reverts commit f5589b42ea499c3f2ed6b9713d1c05f9377c876b. Conflicts: apps/openmw/mwrender/videoplayer.cpp --- apps/openmw/mwrender/videoplayer.cpp | 46 +++------------------------- 1 file changed, 5 insertions(+), 41 deletions(-) diff --git a/apps/openmw/mwrender/videoplayer.cpp b/apps/openmw/mwrender/videoplayer.cpp index 46d33c86d..4b1a23c31 100644 --- a/apps/openmw/mwrender/videoplayer.cpp +++ b/apps/openmw/mwrender/videoplayer.cpp @@ -32,16 +32,6 @@ extern "C" #include #include - -#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) #define av_frame_alloc avcodec_alloc_frame #endif @@ -229,11 +219,8 @@ void PacketQueue::put(AVPacket *pkt) if(!pkt1) throw std::bad_alloc(); pkt1->pkt = *pkt; pkt1->next = NULL; -#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0) - if(pkt1->pkt.destruct == NULL) -#else + if(pkt1->pkt.buf == NULL) -#endif /* LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0) */ { if(av_dup_packet(&pkt1->pkt) < 0) { @@ -438,7 +425,7 @@ class MovieAudioDecoder : public MWSound::Sound_Decoder return -1; /* 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; } } @@ -833,22 +820,6 @@ double VideoState::synchronize_video(AVFrame *src_frame, double pts) * a frame at the time it is allocated. */ static uint64_t global_video_pkt_pts = static_cast(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) { 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; return ret; } -#endif /* LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0) */ 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"); double pts = 0; - if(IS_NOTEQ_NOPTS_VAL(packet->dts)) + if(packet->dts != AV_NOPTS_VALUE) 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 *= 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 codecCtx = pFormatCtx->streams[stream_index]->codec; codec = avcodec_find_decoder(codecCtx->codec_id); -#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0) codecCtx->refcounted_frames = 1; -#endif /* LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0) */ if(!codec || (avcodec_open2(codecCtx, codec, NULL) < 0)) { 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->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; -#endif /* LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56,1,0) */ this->video_thread = boost::thread(video_thread_loop, this); this->refresh_thread = boost::thread(video_refresh, this); break;