summaryrefslogtreecommitdiffstats
path: root/video/out/vo_lavc.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-04-29 16:07:21 +0200
committerJan Ekström <jeebjp@gmail.com>2018-05-03 01:08:44 +0300
commit958053ff56109a38e9f8e0a0aa8786a5f47adb7c (patch)
tree057ea45af11ad3f7cc26e3f42d9e2be426525336 /video/out/vo_lavc.c
parent1a339fa09d25e94833153f299af03e9c44b19a43 (diff)
downloadmpv-958053ff56109a38e9f8e0a0aa8786a5f47adb7c.tar.bz2
mpv-958053ff56109a38e9f8e0a0aa8786a5f47adb7c.tar.xz
vo_lavc: explicitly skip redraw and repeated frames
The user won't want to have those in the video (I think). The core can sporadically issue redraws, which is what you want for actual playback, but not in encode mode. vo_lavc can explicitly detect those and skip them. It only requires switching to a more advanced internal VO API. The comments in vo.h are because vo_lavc draws to one of the images in order to render OSD. This is OK, but might come as a surprise to whoever calls draw_frame, so document it. (Current callers are OK with it.)
Diffstat (limited to 'video/out/vo_lavc.c')
-rw-r--r--video/out/vo_lavc.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/video/out/vo_lavc.c b/video/out/vo_lavc.c
index 848985edc0..2f48e3f750 100644
--- a/video/out/vo_lavc.c
+++ b/video/out/vo_lavc.c
@@ -41,8 +41,6 @@ struct priv {
bool shutdown;
};
-static void draw_image(struct vo *vo, mp_image_t *mpi);
-
static int preinit(struct vo *vo)
{
struct priv *vc = vo->priv;
@@ -158,18 +156,23 @@ static int query_format(struct vo *vo, int format)
return 0;
}
-static void draw_image(struct vo *vo, mp_image_t *mpi)
+static void draw_frame(struct vo *vo, struct vo_frame *voframe)
{
struct priv *vc = vo->priv;
struct encoder_context *enc = vc->enc;
struct encode_lavc_context *ectx = enc->encode_lavc_ctx;
AVCodecContext *avc = enc->encoder;
+ if (voframe->redraw || voframe->repeat || voframe->num_frames < 1)
+ return;
+
+ struct mp_image *mpi = voframe->frames[0];
+
struct mp_osd_res dim = osd_res_from_image_params(vo->params);
osd_draw_on_image(vo->osd, dim, mpi->pts, OSD_DRAW_SUB_ONLY, mpi);
if (vc->shutdown)
- goto done;
+ return;
// Lock for shared timestamp fields.
pthread_mutex_lock(&ectx->lock);
@@ -215,9 +218,6 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
frame->quality = avc->global_quality;
encoder_encode(enc, frame);
av_frame_free(&frame);
-
-done:
- talloc_free(mpi);
}
static void flip_page(struct vo *vo)
@@ -240,7 +240,7 @@ const struct vo_driver video_out_lavc = {
.reconfig2 = reconfig2,
.control = control,
.uninit = uninit,
- .draw_image = draw_image,
+ .draw_frame = draw_frame,
.flip_page = flip_page,
};