From 958053ff56109a38e9f8e0a0aa8786a5f47adb7c Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 29 Apr 2018 16:07:21 +0200 Subject: 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.) --- video/out/vo_lavc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'video/out/vo_lavc.c') 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, }; -- cgit v1.2.3