mirror of https://github.com/mpv-player/mpv
dec_video: make vf_input and hwdec_info statically allocated
The only reason why these structs were dynamically allocated was to avoid recursive includes in stheader.h, which is (or was) a very central file included by almost all other files. (If a struct is referenced via a pointer type only, it can be forward referenced, and the definition of the struct is not needed.) Now that they're out of stheader.h, this difference doesn't matter anymore, and the code can be simplified. Also sneak in some sanity checks.
This commit is contained in:
parent
02f96efc50
commit
4c2fb8f3a2
|
@ -1439,7 +1439,7 @@ static int mp_property_width(m_option_t *prop, int action, void *arg,
|
|||
return M_PROPERTY_UNAVAILABLE;
|
||||
struct sh_video *sh = vd->header->video;
|
||||
return m_property_int_ro(prop, action, arg,
|
||||
vd->vf_input ? vd->vf_input->w : sh->disp_w);
|
||||
vd->vf_input.w ? vd->vf_input.w : sh->disp_w);
|
||||
}
|
||||
|
||||
/// Video display height (RO)
|
||||
|
@ -1451,7 +1451,7 @@ static int mp_property_height(m_option_t *prop, int action, void *arg,
|
|||
return M_PROPERTY_UNAVAILABLE;
|
||||
struct sh_video *sh = vd->header->video;
|
||||
return m_property_int_ro(prop, action, arg,
|
||||
vd->vf_input ? vd->vf_input->h : sh->disp_h);
|
||||
vd->vf_input.h ? vd->vf_input.h : sh->disp_h);
|
||||
}
|
||||
|
||||
static int property_vo_wh(m_option_t *prop, int action, void *arg,
|
||||
|
@ -1554,7 +1554,7 @@ static int mp_property_aspect(m_option_t *prop, int action, void *arg,
|
|||
}
|
||||
case M_PROPERTY_GET: {
|
||||
float aspect = -1;
|
||||
struct mp_image_params *params = d_video->vf_input;
|
||||
struct mp_image_params *params = &d_video->vf_input;
|
||||
if (params && params->d_w && params->d_h) {
|
||||
aspect = (float)params->d_w / params->d_h;
|
||||
} else if (sh_video->disp_w && sh_video->disp_h) {
|
||||
|
|
|
@ -83,9 +83,10 @@ void update_subtitles(struct MPContext *mpctx)
|
|||
struct dec_sub *dec_sub = mpctx->d_sub;
|
||||
assert(track && dec_sub);
|
||||
|
||||
if (mpctx->d_video && mpctx->d_video->vf_input) {
|
||||
struct mp_image_params params = *mpctx->d_video->vf_input;
|
||||
sub_control(dec_sub, SD_CTRL_SET_VIDEO_PARAMS, ¶ms);
|
||||
if (mpctx->d_video) {
|
||||
struct mp_image_params params = mpctx->d_video->vf_input;
|
||||
if (params.imgfmt)
|
||||
sub_control(dec_sub, SD_CTRL_SET_VIDEO_PARAMS, ¶ms);
|
||||
}
|
||||
|
||||
mpctx->osd->video_offset = track->under_timeline ? mpctx->video_offset : 0;
|
||||
|
|
|
@ -131,10 +131,7 @@ int reinit_video_chain(struct MPContext *mpctx)
|
|||
d_video->header = sh;
|
||||
mpctx->initialized_flags |= INITIALIZED_VCODEC;
|
||||
|
||||
// dynamic allocation only to make stheader.h lighter
|
||||
talloc_free(d_video->hwdec_info);
|
||||
d_video->hwdec_info = talloc_zero(d_video, struct mp_hwdec_info);
|
||||
vo_control(mpctx->video_out, VOCTRL_GET_HWDEC_INFO, d_video->hwdec_info);
|
||||
vo_control(mpctx->video_out, VOCTRL_GET_HWDEC_INFO, &d_video->hwdec_info);
|
||||
|
||||
if (stream_control(sh->demuxer->stream, STREAM_CTRL_GET_ASPECT_RATIO, &ar)
|
||||
!= STREAM_UNSUPPORTED)
|
||||
|
@ -236,7 +233,7 @@ static void filter_video(struct MPContext *mpctx, struct mp_image *frame)
|
|||
init_filter_params(mpctx);
|
||||
|
||||
frame->pts = d_video->pts;
|
||||
mp_image_set_params(frame, d_video->vf_input);
|
||||
mp_image_set_params(frame, &d_video->vf_input); // force csp/aspect overrides
|
||||
vf_filter_frame(d_video->vfilter, frame);
|
||||
filter_output_queued_frame(mpctx);
|
||||
}
|
||||
|
|
|
@ -385,9 +385,7 @@ int mpcodecs_reconfig_vo(struct dec_video *d_video,
|
|||
|
||||
d_video->vf_initialized = 1;
|
||||
|
||||
if (!d_video->vf_input)
|
||||
d_video->vf_input = talloc(sh, struct mp_image_params);
|
||||
*d_video->vf_input = p;
|
||||
d_video->vf_input = p;
|
||||
|
||||
if (opts->gamma_gamma != 1000)
|
||||
video_set_colors(d_video, "gamma", opts->gamma_gamma);
|
||||
|
|
|
@ -34,8 +34,8 @@ struct dec_video {
|
|||
const struct vd_functions *vd_driver;
|
||||
int vf_initialized; // -1 failed, 0 not done, 1 done
|
||||
long vf_reconfig_count; // incremented each mpcodecs_reconfig_vo() call
|
||||
struct mp_image_params *vf_input; // video filter input params
|
||||
struct mp_hwdec_info *hwdec_info; // video output hwdec handles
|
||||
struct mp_image_params vf_input; // video filter input params
|
||||
struct mp_hwdec_info hwdec_info; // video output hwdec handles
|
||||
struct sh_stream *header;
|
||||
|
||||
char *decoder_desc;
|
||||
|
|
|
@ -224,7 +224,7 @@ static bool probe_hwdec(struct dec_video *vd, bool autoprobe, enum hwdec_type ap
|
|||
return false;
|
||||
}
|
||||
const char *hw_decoder = NULL;
|
||||
int r = hwdec_probe(hwdec, vd->hwdec_info, decoder, &hw_decoder);
|
||||
int r = hwdec_probe(hwdec, &vd->hwdec_info, decoder, &hw_decoder);
|
||||
if (r >= 0) {
|
||||
*use_hwdec = hwdec;
|
||||
*use_decoder = hw_decoder;
|
||||
|
@ -380,7 +380,7 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
|
|||
if (!lavc_codec)
|
||||
return;
|
||||
|
||||
ctx->hwdec_info = vd->hwdec_info;
|
||||
ctx->hwdec_info = &vd->hwdec_info;
|
||||
|
||||
ctx->do_dr1 = ctx->do_hw_dr1 = 0;
|
||||
ctx->pix_fmt = PIX_FMT_NONE;
|
||||
|
|
Loading…
Reference in New Issue