summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2015-06-17 23:16:43 +0200
committerAlfred E. Heggestad <aeh@db.org>2015-06-17 23:16:43 +0200
commit69d26555b437261be0d7e6c6337a4bc412c43988 (patch)
tree4a8ca1676bb0937c01c24f057d11b3211d8e1eda /modules
parent8374253c7f7bb2583df9246e6f840e87958b08ec (diff)
avformat: fix segfault, use av_frame_alloc()
Diffstat (limited to 'modules')
-rw-r--r--modules/avformat/avf.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/modules/avformat/avf.c b/modules/avformat/avf.c
index 71b9557..32e5cfb 100644
--- a/modules/avformat/avf.c
+++ b/modules/avformat/avf.c
@@ -1,7 +1,7 @@
/**
* @file avf.c libavformat video-source
*
- * Copyright (C) 2010 Creytiv.com
+ * Copyright (C) 2010 - 2015 Creytiv.com
*/
#define _BSD_SOURCE 1
#include <unistd.h>
@@ -17,6 +17,19 @@
#include <libswscale/swscale.h>
+/**
+ * @defgroup avformat avformat
+ *
+ * Video source using FFmpeg/libav libavformat
+ *
+ *
+ * Example config:
+ \verbatim
+ video_source avformat,/tmp/testfile.mp4
+ \endverbatim
+ */
+
+
/* extra const-correctness added in 0.9.0 */
/* note: macports has LIBSWSCALE_VERSION_MAJOR == 1 */
/* #if LIBSWSCALE_VERSION_INT >= ((0<<16) + (9<<8) + (0)) */
@@ -89,22 +102,24 @@ static void destructor(void *arg)
}
-static void handle_packet(struct vidsrc_st *st, AVPacket *pkt)
+static void handle_packet(struct vidsrc_st *st, const AVPacket *pkt)
{
AVPicture pict;
+ AVFrame *frame = NULL;
struct vidframe vf;
struct vidsz sz;
unsigned i;
if (st->codec) {
- AVFrame frame;
int got_pict, ret;
+ frame = av_frame_alloc();
+
#if LIBAVCODEC_VERSION_INT <= ((52<<16)+(23<<8)+0)
- ret = avcodec_decode_video(st->ctx, &frame, &got_pict,
+ ret = avcodec_decode_video(st->ctx, frame, &got_pict,
pkt->data, pkt->size);
#else
- ret = avcodec_decode_video2(st->ctx, &frame,
+ ret = avcodec_decode_video2(st->ctx, frame,
&got_pict, pkt);
#endif
if (ret < 0 || !got_pict)
@@ -146,7 +161,7 @@ static void handle_packet(struct vidsrc_st *st, AVPacket *pkt)
return;
ret = sws_scale(st->sws,
- SRCSLICE_CAST frame.data, frame.linesize,
+ SRCSLICE_CAST frame->data, frame->linesize,
0, st->sz.h, pict.data, pict.linesize);
if (ret <= 0)
goto end;
@@ -168,6 +183,8 @@ static void handle_packet(struct vidsrc_st *st, AVPacket *pkt)
end:
if (st->codec)
avpicture_free(&pict);
+ if (frame)
+ av_frame_free(&frame);
}