dec_video: remove "initialized" field

It's redundant.
This commit is contained in:
wm4 2013-11-23 21:38:39 +01:00
parent 904c73d2d2
commit 02f96efc50
3 changed files with 9 additions and 16 deletions

View File

@ -142,9 +142,7 @@ int reinit_video_chain(struct MPContext *mpctx)
recreate_video_filters(mpctx);
video_init_best_codec(d_video, opts->video_decoders);
if (!d_video->initialized)
if (!video_init_best_codec(d_video, opts->video_decoders))
goto err_out;
bool saver_state = opts->pause || !opts->stop_screensaver;

View File

@ -115,28 +115,22 @@ void video_reinit_vo(struct dec_video *d_video)
void video_uninit(struct dec_video *d_video)
{
if (d_video->initialized) {
if (d_video->vd_driver) {
mp_tmsg(MSGT_DECVIDEO, MSGL_V, "Uninit video.\n");
d_video->vd_driver->uninit(d_video);
}
talloc_free(d_video->priv);
d_video->priv = NULL;
vf_uninit_filter_chain(d_video->vfilter);
d_video->vfilter = NULL;
talloc_free(d_video);
}
static int init_video_codec(struct dec_video *d_video, const char *decoder)
{
assert(!d_video->initialized);
if (!d_video->vd_driver->init(d_video, decoder)) {
mp_tmsg(MSGT_DECVIDEO, MSGL_V, "Video decoder init failed.\n");
//uninit_video(d_video);
return 0;
}
d_video->initialized = 1;
d_video->prev_codec_reordered_pts = MP_NOPTS_VALUE;
d_video->prev_sorted_pts = MP_NOPTS_VALUE;
return 1;
@ -168,9 +162,9 @@ static const struct vd_functions *find_driver(const char *name)
return NULL;
}
int video_init_best_codec(struct dec_video *d_video, char* video_decoders)
bool video_init_best_codec(struct dec_video *d_video, char* video_decoders)
{
assert(!d_video->initialized);
assert(!d_video->vd_driver);
struct mp_decoder_entry *decoder = NULL;
struct mp_decoder_list *list =
@ -195,7 +189,7 @@ int video_init_best_codec(struct dec_video *d_video, char* video_decoders)
"%s:%s\n", sel->family, sel->decoder);
}
if (d_video->initialized) {
if (d_video->vd_driver) {
d_video->decoder_desc =
talloc_asprintf(d_video, "%s [%s:%s]", decoder->desc, decoder->family,
decoder->decoder);
@ -208,7 +202,7 @@ int video_init_best_codec(struct dec_video *d_video, char* video_decoders)
}
talloc_free(list);
return d_video->initialized;
return !!d_video->vd_driver;
}
void *video_decode(struct dec_video *d_video, struct demux_packet *packet,

View File

@ -19,6 +19,8 @@
#ifndef MPLAYER_DEC_VIDEO_H
#define MPLAYER_DEC_VIDEO_H
#include <stdbool.h>
#include "demux/stheader.h"
#include "video/hwdec.h"
#include "video/mp_image.h"
@ -34,7 +36,6 @@ struct dec_video {
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
int initialized;
struct sh_stream *header;
char *decoder_desc;
@ -60,7 +61,7 @@ struct dec_video {
struct mp_decoder_list *video_decoder_list(void);
int video_init_best_codec(struct dec_video *d_video, char* video_decoders);
bool video_init_best_codec(struct dec_video *d_video, char* video_decoders);
void video_uninit(struct dec_video *d_video);
struct demux_packet;