summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-21 17:47:38 +0100
committerwm4 <wm4@nowhere>2013-12-21 20:50:10 +0100
commit2eefa31c886723bcc30664ea9fe3e2420f2cc0c6 (patch)
tree4f3f6a163a46cf03ba4a2bc50b2527ebce40edc2 /video
parent426ebbae5ff578923a83a4395ff499f0348f7dcc (diff)
downloadmpv-2eefa31c886723bcc30664ea9fe3e2420f2cc0c6.tar.bz2
mpv-2eefa31c886723bcc30664ea9fe3e2420f2cc0c6.tar.xz
video/decode: mp_msg conversions
Doesn't cover vdpau/vaapi parts yet, because these are a bit messier.
Diffstat (limited to 'video')
-rw-r--r--video/decode/dec_video.c64
-rw-r--r--video/decode/dec_video.h2
-rw-r--r--video/decode/lavc.h1
-rw-r--r--video/decode/vd_lavc.c58
-rw-r--r--video/decode/vda.c11
5 files changed, 71 insertions, 65 deletions
diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c
index b150816a90..bfd2d84ab4 100644
--- a/video/decode/dec_video.c
+++ b/video/decode/dec_video.c
@@ -87,14 +87,14 @@ int video_set_colors(struct dec_video *d_video, const char *item, int value)
data.item = item;
data.value = value;
- mp_msg(MSGT_DECVIDEO, MSGL_V, "set video colors %s=%d \n", item, value);
+ MP_VERBOSE(d_video, "set video colors %s=%d \n", item, value);
if (d_video->vfilter) {
int ret = video_vf_vo_control(d_video, VFCTRL_SET_EQUALIZER, &data);
if (ret == CONTROL_TRUE)
return 1;
}
- mp_msg(MSGT_DECVIDEO, MSGL_V, "Video attribute '%s' is not supported by selected vo.\n",
- item);
+ MP_VERBOSE(d_video, "Video attribute '%s' is not supported by selected vo.\n",
+ item);
return 0;
}
@@ -104,7 +104,7 @@ int video_get_colors(struct dec_video *d_video, const char *item, int *value)
data.item = item;
- mp_msg(MSGT_DECVIDEO, MSGL_V, "get video colors %s \n", item);
+ MP_VERBOSE(d_video, "get video colors %s \n", item);
if (d_video->vfilter) {
int ret = video_vf_vo_control(d_video, VFCTRL_GET_EQUALIZER, &data);
if (ret == CONTROL_TRUE) {
@@ -119,7 +119,7 @@ void video_uninit(struct dec_video *d_video)
{
mp_image_unrefp(&d_video->waiting_decoded_mpi);
if (d_video->vd_driver) {
- mp_msg(MSGT_DECVIDEO, MSGL_V, "Uninit video.\n");
+ MP_VERBOSE(d_video, "Uninit video.\n");
d_video->vd_driver->uninit(d_video);
}
talloc_free(d_video->priv);
@@ -130,7 +130,7 @@ void video_uninit(struct dec_video *d_video)
static int init_video_codec(struct dec_video *d_video, const char *decoder)
{
if (!d_video->vd_driver->init(d_video, decoder)) {
- mp_msg(MSGT_DECVIDEO, MSGL_V, "Video decoder init failed.\n");
+ MP_VERBOSE(d_video, "Video decoder init failed.\n");
return 0;
}
return 1;
@@ -179,15 +179,15 @@ bool video_init_best_codec(struct dec_video *d_video, char* video_decoders)
const struct vd_functions *driver = find_driver(sel->family);
if (!driver)
continue;
- mp_msg(MSGT_DECVIDEO, MSGL_V, "Opening video decoder %s:%s\n",
- sel->family, sel->decoder);
+ MP_VERBOSE(d_video, "Opening video decoder %s:%s\n",
+ sel->family, sel->decoder);
d_video->vd_driver = driver;
if (init_video_codec(d_video, sel->decoder)) {
decoder = sel;
break;
}
d_video->vd_driver = NULL;
- mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Video decoder init failed for "
+ MP_WARN(d_video, "Video decoder init failed for "
"%s:%s\n", sel->family, sel->decoder);
}
@@ -195,11 +195,10 @@ bool video_init_best_codec(struct dec_video *d_video, char* video_decoders)
d_video->decoder_desc =
talloc_asprintf(d_video, "%s [%s:%s]", decoder->desc, decoder->family,
decoder->decoder);
- mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Selected video codec: %s\n",
- d_video->decoder_desc);
+ MP_INFO(d_video, "Selected video codec: %s\n",
+ d_video->decoder_desc);
} else {
- mp_msg(MSGT_DECVIDEO, MSGL_ERR,
- "Failed to initialize a video decoder for codec '%s'.\n",
+ MP_ERR(d_video, "Failed to initialize a video decoder for codec '%s'.\n",
d_video->header->codec ? d_video->header->codec : "<unknown>");
}
@@ -216,7 +215,7 @@ static void add_pts_to_sort(struct dec_video *d_video, double pts)
d_video->num_buffered_pts = delay;
if (d_video->num_buffered_pts ==
sizeof(d_video->buffered_pts) / sizeof(double))
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Too many buffered pts\n");
+ MP_ERR(d_video, "Too many buffered pts\n");
else {
int i, j;
for (i = 0; i < d_video->num_buffered_pts; i++)
@@ -244,8 +243,7 @@ static double retrieve_sorted_pts(struct dec_video *d_video, double codec_pts)
d_video->num_buffered_pts--;
sorted_pts = d_video->buffered_pts[d_video->num_buffered_pts];
} else {
- mp_msg(MSGT_CPLAYER, MSGL_ERR,
- "No pts value from demuxer to use for frame!\n");
+ MP_ERR(d_video, "No pts value from demuxer to use for frame!\n");
sorted_pts = MP_NOPTS_VALUE;
}
@@ -277,9 +275,8 @@ static double retrieve_sorted_pts(struct dec_video *d_video, double codec_pts)
}
if (probcount1 >= probcount2 * 1.5 + 2) {
d_video->pts_assoc_mode = 3 - d_video->pts_assoc_mode;
- mp_msg(MSGT_DECVIDEO, MSGL_WARN,
- "Switching to pts association mode %d.\n",
- d_video->pts_assoc_mode);
+ MP_WARN(d_video, "Switching to pts association mode %d.\n",
+ d_video->pts_assoc_mode);
}
}
return d_video->pts_assoc_mode == 1 ? codec_pts : sorted_pts;
@@ -347,7 +344,7 @@ struct mp_image *video_decode(struct dec_video *d_video,
if (!opts->correct_pts || pts == MP_NOPTS_VALUE) {
if (opts->correct_pts)
- mp_msg(MSGT_DECVIDEO, MSGL_WARN, "No video PTS! Making something up.\n");
+ MP_WARN(d_video, "No video PTS! Making something up.\n");
double frame_time = 1.0f / (d_video->fps > 0 ? d_video->fps : 25);
double base = d_video->last_packet_pdts;
@@ -359,8 +356,8 @@ struct mp_image *video_decode(struct dec_video *d_video,
}
if (d_video->decoded_pts != MP_NOPTS_VALUE && pts <= d_video->decoded_pts) {
- mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Non-monotonic video pts: %f <= %f\n",
- pts, d_video->decoded_pts);
+ MP_WARN(d_video, "Non-monotonic video pts: %f <= %f\n",
+ pts, d_video->decoded_pts);
}
if (d_video->has_broken_packet_pts < 0)
@@ -380,13 +377,12 @@ int video_reconfig_filters(struct dec_video *d_video,
struct mp_image_params p = *params;
struct sh_video *sh = d_video->header->video;
- mp_msg(MSGT_DECVIDEO, MSGL_V,
- "VIDEO: %dx%d %5.3f fps %5.1f kbps (%4.1f kB/s)\n",
- p.w, p.h, sh->fps, sh->i_bps * 0.008,
- sh->i_bps / 1000.0);
+ MP_VERBOSE(d_video, "VIDEO: %dx%d %5.3f fps %5.1f kbps (%4.1f kB/s)\n",
+ p.w, p.h, sh->fps, sh->i_bps * 0.008,
+ sh->i_bps / 1000.0);
- mp_msg(MSGT_DECVIDEO, MSGL_V, "VDec: vo config request - %d x %d (%s)\n",
- p.w, p.h, vo_format_name(p.imgfmt));
+ MP_VERBOSE(d_video, "VDec: vo config request - %d x %d (%s)\n",
+ p.w, p.h, vo_format_name(p.imgfmt));
float decoder_aspect = p.d_w / (float)p.d_h;
if (d_video->initial_decoder_aspect == 0)
@@ -410,9 +406,9 @@ int video_reconfig_filters(struct dec_video *d_video,
vf_set_dar(&p.d_w, &p.d_h, p.w, p.h, force_aspect);
if (abs(p.d_w - p.w) >= 4 || abs(p.d_h - p.h) >= 4) {
- mp_msg(MSGT_CPLAYER, MSGL_V, "Aspect ratio is %.2f:1 - "
- "scaling to correct movie aspect.\n", sh->aspect);
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ASPECT=%1.4f\n", sh->aspect);
+ MP_VERBOSE(d_video, "Aspect ratio is %.2f:1 - "
+ "scaling to correct movie aspect.\n", sh->aspect);
+ MP_SMODE(d_video, "ID_VIDEO_ASPECT=%1.4f\n", sh->aspect);
} else {
p.d_w = p.w;
p.d_h = p.h;
@@ -430,11 +426,11 @@ int video_reconfig_filters(struct dec_video *d_video,
mp_image_params_guess_csp(&p);
// Time to config libvo!
- mp_msg(MSGT_CPLAYER, MSGL_V, "VO Config (%dx%d->%dx%d,0x%X)\n",
- p.w, p.h, p.d_w, p.d_h, p.imgfmt);
+ MP_VERBOSE(d_video, "VO Config (%dx%d->%dx%d,0x%X)\n",
+ p.w, p.h, p.d_w, p.d_h, p.imgfmt);
if (vf_reconfig(d_video->vfilter, &p) < 0) {
- mp_msg(MSGT_CPLAYER, MSGL_WARN, "FATAL: Cannot initialize video driver.\n");
+ MP_WARN(d_video, "FATAL: Cannot initialize video driver.\n");
return -1;
}
diff --git a/video/decode/dec_video.h b/video/decode/dec_video.h
index c0a8fcffe1..7805d89c48 100644
--- a/video/decode/dec_video.h
+++ b/video/decode/dec_video.h
@@ -29,6 +29,8 @@ struct mp_decoder_list;
struct vo;
struct dec_video {
+ struct mp_log *log;
+ struct mpv_global *global;
struct MPOpts *opts;
struct vf_chain *vfilter; // video filter chain
struct vo *vo; // (still) needed by video_set/get_colors
diff --git a/video/decode/lavc.h b/video/decode/lavc.h
index ead147ab18..867488de95 100644
--- a/video/decode/lavc.h
+++ b/video/decode/lavc.h
@@ -21,6 +21,7 @@ enum hwdec_type {
};
typedef struct lavc_ctx {
+ struct mp_log *log;
struct MPOpts *opts;
AVCodecContext *avctx;
AVFrame *pic;
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 8a8d2b6abc..7530eb0fa5 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -127,7 +127,7 @@ static bool hwdec_codec_allowed(struct dec_video *vd, const char *codec)
return false;
}
-static enum AVDiscard str2AVDiscard(char *str)
+static enum AVDiscard str2AVDiscard(struct dec_video *vd, char *str)
{
if (!str) return AVDISCARD_DEFAULT;
if (strcasecmp(str, "none" ) == 0) return AVDISCARD_NONE;
@@ -136,7 +136,7 @@ static enum AVDiscard str2AVDiscard(char *str)
if (strcasecmp(str, "bidir" ) == 0) return AVDISCARD_BIDIR;
if (strcasecmp(str, "nonkey" ) == 0) return AVDISCARD_NONKEY;
if (strcasecmp(str, "all" ) == 0) return AVDISCARD_ALL;
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Unknown discard value %s\n", str);
+ MP_ERR(vd, "Unknown discard value %s\n", str);
return AVDISCARD_DEFAULT;
}
@@ -218,8 +218,8 @@ static bool probe_hwdec(struct dec_video *vd, bool autoprobe, enum hwdec_type ap
{
struct vd_lavc_hwdec *hwdec = find_hwcodec(api);
if (!hwdec) {
- mp_msg(MSGT_DECVIDEO, MSGL_V, "Requested hardware decoder not "
- "compiled.\n");
+ MP_VERBOSE(vd, "Requested hardware decoder not "
+ "compiled.\n");
return false;
}
const char *hw_decoder = NULL;
@@ -229,10 +229,10 @@ static bool probe_hwdec(struct dec_video *vd, bool autoprobe, enum hwdec_type ap
*use_decoder = hw_decoder;
return true;
} else if (r == HWDEC_ERR_NO_CODEC) {
- mp_msg(MSGT_DECVIDEO, MSGL_V, "Hardware decoder '%s' not found in "
- "libavcodec.\n", hw_decoder ? hw_decoder : decoder);
+ MP_VERBOSE(vd, "Hardware decoder '%s' not found in "
+ "libavcodec.\n", hw_decoder ? hw_decoder : decoder);
} else if (r == HWDEC_ERR_NO_CTX && !autoprobe) {
- mp_msg(MSGT_DECVIDEO, MSGL_WARN, "VO does not support requested "
+ MP_WARN(vd, "VO does not support requested "
"hardware decoder.\n");
}
return false;
@@ -243,11 +243,12 @@ static int init(struct dec_video *vd, const char *decoder)
{
vd_ffmpeg_ctx *ctx;
ctx = vd->priv = talloc_zero(NULL, vd_ffmpeg_ctx);
+ ctx->log = vd->log;
ctx->opts = vd->opts;
ctx->non_dr1_pool = talloc_steal(ctx, mp_image_pool_new(16));
if (bstr_endswith0(bstr0(decoder), "_vdpau")) {
- mp_msg(MSGT_DECVIDEO, MSGL_WARN, "VDPAU decoder '%s' was requested. "
+ MP_WARN(vd, "VDPAU decoder '%s' was requested. "
"This way of enabling hardware\ndecoding is not supported "
"anymore. Use --hwdec=vdpau instead.\nThe --hwdec-codec=... "
"option can be used to restrict which codecs are\nenabled, "
@@ -272,24 +273,24 @@ static int init(struct dec_video *vd, const char *decoder)
&hwdec, &hw_decoder);
}
} else {
- mp_msg(MSGT_DECVIDEO, MSGL_V, "Not trying to use hardware decoding: "
- "codec %s is blacklisted by user.\n", decoder);
+ MP_VERBOSE(vd, "Not trying to use hardware decoding: "
+ "codec %s is blacklisted by user.\n", decoder);
}
if (hwdec) {
ctx->software_fallback_decoder = talloc_strdup(ctx, decoder);
if (hw_decoder)
decoder = hw_decoder;
- mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Trying to use hardware decoding.\n");
+ MP_INFO(vd, "Trying to use hardware decoding.\n");
} else if (vd->opts->hwdec_api != HWDEC_NONE) {
- mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Using software decoding.\n");
+ MP_INFO(vd, "Using software decoding.\n");
}
init_avctx(vd, decoder, hwdec);
if (!ctx->avctx) {
if (ctx->software_fallback_decoder) {
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Error initializing hardware "
- "decoding, falling back to software decoding.\n");
+ MP_ERR(vd, "Error initializing hardware decoding, "
+ "falling back to software decoding.\n");
decoder = ctx->software_fallback_decoder;
ctx->software_fallback_decoder = NULL;
init_avctx(vd, decoder, NULL);
@@ -420,14 +421,13 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
avctx->flags |= lavc_param->bitexact;
avctx->flags2 |= lavc_param->fast;
- avctx->skip_loop_filter = str2AVDiscard(lavc_param->skip_loop_filter_str);
- avctx->skip_idct = str2AVDiscard(lavc_param->skip_idct_str);
- avctx->skip_frame = str2AVDiscard(lavc_param->skip_frame_str);
+ avctx->skip_loop_filter = str2AVDiscard(vd, lavc_param->skip_loop_filter_str);
+ avctx->skip_idct = str2AVDiscard(vd, lavc_param->skip_idct_str);
+ avctx->skip_frame = str2AVDiscard(vd, lavc_param->skip_frame_str);
if (lavc_param->avopt) {
if (parse_avopts(avctx, lavc_param->avopt) < 0) {
- mp_msg(MSGT_DECVIDEO, MSGL_ERR,
- "Your options /%s/ look like gibberish to me pal\n",
+ MP_ERR(vd, "Your options /%s/ look like gibberish to me pal\n",
lavc_param->avopt);
uninit_avctx(vd);
return;
@@ -448,6 +448,9 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
if (mp_rawvideo) {
avctx->pix_fmt = imgfmt2pixfmt(sh->format);
avctx->codec_tag = 0;
+ if (avctx->pix_fmt == AV_PIX_FMT_NONE && sh->format)
+ MP_ERR(vd, "Image format %s not supported by lavc.\n",
+ mp_imgfmt_to_name(sh->format));
}
if (sh->lav_headers)
@@ -455,7 +458,7 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
/* open it */
if (avcodec_open2(avctx, lavc_codec, NULL) < 0) {
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Could not open codec.\n");
+ MP_ERR(vd, "Could not open codec.\n");
uninit_avctx(vd);
return;
}
@@ -468,7 +471,7 @@ static void uninit_avctx(struct dec_video *vd)
if (avctx) {
if (avctx->codec && avcodec_close(avctx) < 0)
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Could not close codec.\n");
+ MP_ERR(vd, "Could not close codec.\n");
av_freep(&avctx->extradata);
av_freep(&avctx->slice_offset);
@@ -508,6 +511,9 @@ static void update_image_params(struct dec_video *vd, AVFrame *frame,
if (pix_fmt != ctx->pix_fmt) {
ctx->pix_fmt = pix_fmt;
ctx->best_csp = pixfmt2imgfmt(pix_fmt);
+ if (!ctx->best_csp)
+ MP_ERR(vd, "lavc pixel format %s not supported.\n",
+ av_get_pix_fmt_name(pix_fmt));
}
int d_w, d_h;
@@ -532,10 +538,10 @@ static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx,
struct dec_video *vd = avctx->opaque;
vd_ffmpeg_ctx *ctx = vd->priv;
- mp_msg(MSGT_DECVIDEO, MSGL_V, "Pixel formats supported by decoder:");
+ MP_VERBOSE(vd, "Pixel formats supported by decoder:");
for (int i = 0; fmt[i] != AV_PIX_FMT_NONE; i++)
- mp_msg(MSGT_DECVIDEO, MSGL_V, " %s", av_get_pix_fmt_name(fmt[i]));
- mp_msg(MSGT_DECVIDEO, MSGL_V, "\n");
+ MP_VERBOSE(vd, " %s", av_get_pix_fmt_name(fmt[i]));
+ MP_VERBOSE(vd, "\n");
assert(ctx->hwdec);
@@ -732,7 +738,7 @@ static int decode(struct dec_video *vd, struct demux_packet *packet,
ret = avcodec_decode_video2(avctx, ctx->pic, &got_picture, &pkt);
if (ret < 0) {
- mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Error while decoding frame!\n");
+ MP_WARN(vd, "Error while decoding frame!\n");
return -1;
}
@@ -762,7 +768,7 @@ static int force_fallback(struct dec_video *vd)
vd_ffmpeg_ctx *ctx = vd->priv;
if (ctx->software_fallback_decoder) {
uninit_avctx(vd);
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Error using hardware "
+ MP_ERR(vd, "Error using hardware "
"decoding, falling back to software decoding.\n");
const char *decoder = ctx->software_fallback_decoder;
ctx->software_fallback_decoder = NULL;
diff --git a/video/decode/vda.c b/video/decode/vda.c
index 7a21c5e10a..ab6f033455 100644
--- a/video/decode/vda.c
+++ b/video/decode/vda.c
@@ -73,16 +73,17 @@ static const struct vda_error vda_errors[] = {
{ 0, NULL },
};
-static void print_vda_error(int lev, char *message, int error_code)
+static void print_vda_error(struct mp_log *log, int lev, char *message,
+ int error_code)
{
for (int n = 0; vda_errors[n].code < 0; n++)
if (vda_errors[n].code == error_code) {
- mp_msg(MSGT_DECVIDEO, lev, "%s: %s (%d)\n",
- message, vda_errors[n].reason, error_code);
+ mp_msg_log(log, lev, "%s: %s (%d)\n",
+ message, vda_errors[n].reason, error_code);
return;
}
- mp_msg(MSGT_DECVIDEO, lev, "%s: %d\n", message, error_code);
+ mp_msg_log(log, lev, "%s: %d\n", message, error_code);
}
static int probe(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info,
@@ -134,7 +135,7 @@ static int init_vda_decoder(struct lavc_ctx *ctx)
&p->vda_ctx, ctx->avctx->extradata, ctx->avctx->extradata_size);
if (status) {
- print_vda_error(MSGL_ERR, "[vda] failed to init decoder", status);
+ print_vda_error(ctx->log, "failed to init VDA decoder", status);
return -1;
}