Skip to content

Commit

Permalink
player/command: reinit video chain when decoder thread count changes
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-heinrich committed May 11, 2024
1 parent 3874145 commit d4d4529
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 22 deletions.
11 changes: 11 additions & 0 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "options/m_config_frontend.h"
#include "options/parse_configfile.h"
#include "osdep/getpid.h"
#include "video/decode/vd_lavc.h"
#include "video/out/gpu/context.h"
#include "video/out/vo.h"
#include "video/csputils.h"
Expand Down Expand Up @@ -7388,6 +7389,16 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags,
mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global);
}

if (opt_ptr == &opts->vd_lavc_params->threads) {
struct track *track = mpctx->current_track[0][STREAM_VIDEO];
uninit_video_chain(mpctx);
reinit_video_chain(mpctx);
if (track)
queue_seek(mpctx, MPSEEK_RELATIVE, 0.0, MPSEEK_EXACT, 0);

mp_wakeup_core(mpctx);
}

if (opt_ptr == &opts->vo->video_driver_list ||
opt_ptr == &opts->ra_ctx_opts->context_list ||
opt_ptr == &opts->ra_ctx_opts->context_type) {
Expand Down
24 changes: 2 additions & 22 deletions video/decode/vd_lavc.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@

#include "options/m_option.h"

#include "vd_lavc.h"

static void init_avctx(struct mp_filter *vd);
static void uninit_avctx(struct mp_filter *vd);

Expand All @@ -69,28 +71,6 @@ static int hwdec_opt_help(struct mp_log *log, const m_option_t *opt,

#define OPT_BASE_STRUCT struct vd_lavc_params

struct vd_lavc_params {
bool fast;
int film_grain;
bool show_all;
int skip_loop_filter;
int skip_idct;
int skip_frame;
int framedrop;
int threads;
bool bitexact;
bool old_x264;
bool apply_cropping;
bool check_hw_profile;
int software_fallback;
char **avopts;
int dr;
char **hwdec_api;
char *hwdec_codecs;
int hwdec_image_format;
int hwdec_extra_frames;
};

static const struct m_opt_choice_alternatives discard_names[] = {
{"none", AVDISCARD_NONE},
{"default", AVDISCARD_DEFAULT},
Expand Down
28 changes: 28 additions & 0 deletions video/decode/vd_lavc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef MPLAYER_VD_LAVC
#define MPLAYER_VD_LAVC

#include <stdbool.h>

struct vd_lavc_params {
bool fast;
int film_grain;
bool show_all;
int skip_loop_filter;
int skip_idct;
int skip_frame;
int framedrop;
int threads;
bool bitexact;
bool old_x264;
bool apply_cropping;
bool check_hw_profile;
int software_fallback;
char **avopts;
int dr;
char **hwdec_api;
char *hwdec_codecs;
int hwdec_image_format;
int hwdec_extra_frames;
};

#endif

0 comments on commit d4d4529

Please sign in to comment.