mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 07:21:12 +00:00
add support for ffmpeg29 thanks to Andreas Cadhalpun; https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=803848
This commit is contained in:
parent
19cd987208
commit
8d2990cc03
33
extern/osg-ffmpeg-videoplayer/videostate.cpp
vendored
33
extern/osg-ffmpeg-videoplayer/videostate.cpp
vendored
@ -90,16 +90,6 @@ void PacketQueue::put(AVPacket *pkt)
|
|||||||
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 +303,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 +344,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 +378,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 +583,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…
x
Reference in New Issue
Block a user