summaryrefslogtreecommitdiffstats
path: root/video/decode/vd_lavc.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-01-24 12:43:36 +0100
committerwm4 <wm4@nowhere>2013-01-24 12:43:36 +0100
commitc162b6d64d696e2a7bab2dc6b6e6fe19f671e654 (patch)
tree0a64497a911c2dffa29ff8c1f133669a92750c87 /video/decode/vd_lavc.c
parent64b0395e21ccc3c79f95e37792f66f19245046e7 (diff)
downloadmpv-c162b6d64d696e2a7bab2dc6b6e6fe19f671e654.tar.bz2
mpv-c162b6d64d696e2a7bab2dc6b6e6fe19f671e654.tar.xz
vd_lavc: add stupid hack to fix decoding of some files with Libav 0.8.x
The decoder returns with AVFrame.format not correctly set for some h264 files (strangely only some). We have to access AVCodecContext.pix_fmt instead. On newer libavcodec versions, it's the other way around: the AVCodecContext.pix_fmt may be incorrectly set on pixel format changes, and you are supposed to use AVFrame.format. The same problem probably exists on older ffmpeg versions too.
Diffstat (limited to 'video/decode/vd_lavc.c')
-rw-r--r--video/decode/vd_lavc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 9dbb07ee16..e2fc8f47e2 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -405,6 +405,11 @@ static int init_vo(sh_video_t *sh, AVFrame *frame)
int width = frame->width;
int height = frame->height;
float aspect = av_q2d(frame->sample_aspect_ratio) * width / height;
+ int pix_fmt = frame->format;
+
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 40, 0)
+ pix_fmt = ctx->avctx->pix_fmt;
+#endif
/* Reconfiguring filter/VO chain may invalidate direct rendering buffers
* we have allocated for libavcodec (including the VDPAU HW decoding
@@ -413,7 +418,7 @@ static int init_vo(sh_video_t *sh, AVFrame *frame)
*/
if (av_cmp_q(frame->sample_aspect_ratio, ctx->last_sample_aspect_ratio) ||
width != sh->disp_w || height != sh->disp_h ||
- frame->format != ctx->pix_fmt || !ctx->vo_initialized)
+ pix_fmt != ctx->pix_fmt || !ctx->vo_initialized)
{
mp_image_pool_clear(ctx->non_dr1_pool);
ctx->vo_initialized = 0;
@@ -430,8 +435,8 @@ static int init_vo(sh_video_t *sh, AVFrame *frame)
sh->disp_w = width;
sh->disp_h = height;
- ctx->pix_fmt = frame->format;
- ctx->best_csp = pixfmt2imgfmt(frame->format);
+ ctx->pix_fmt = pix_fmt;
+ ctx->best_csp = pixfmt2imgfmt(pix_fmt);
sh->colorspace = avcol_spc_to_mp_csp(ctx->avctx->colorspace);
sh->color_range = avcol_range_to_mp_csp_levels(ctx->avctx->color_range);
@@ -624,8 +629,6 @@ static int decode(struct sh_video *sh, struct demux_packet *packet, void *data,
assert(mpi->planes[0]);
- assert(mpi->imgfmt == pixfmt2imgfmt(pic->format));
-
mpi->colorspace = sh->colorspace;
mpi->levels = sh->color_range;
mpi->qscale = pic->qscale_table;