diff options
author | wm4 <wm4@nowhere> | 2017-10-30 21:07:38 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-10-30 21:07:48 +0100 |
commit | a18a7cd4f568aa934be30b2cdf813a0879b8db19 (patch) | |
tree | 1f859ec4ba2f2fa8dcabcd443591b29134053d74 | |
parent | a7f4ecb01299835a1afe5cc051be1e9bb5d4f15d (diff) |
vd_lavc: move display mastering data stuff to mp_image
This is where it should be. It only wasn't because of an old libavcodec
bug, that returned the side data only on every IDR. This required some
sort of caching, which is now dropped. (mp_image wouldn't have been able
to do this kind of caching, because this code is stateless.) We don't
support these old libavcodec versions anymore, which is why this is not
needed anymore.
Also move initialization of rotation/stereo stuff to dec_video.c.
-rw-r--r-- | video/decode/dec_video.c | 3 | ||||
-rw-r--r-- | video/decode/lavc.h | 3 | ||||
-rw-r--r-- | video/decode/vd_lavc.c | 39 | ||||
-rw-r--r-- | video/mp_image.c | 19 |
4 files changed, 22 insertions, 42 deletions
diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c index 67c5eaccd7..ae0f9e27a4 100644 --- a/video/decode/dec_video.c +++ b/video/decode/dec_video.c @@ -227,6 +227,9 @@ static void fix_image_params(struct dec_video *d_video, if (p.p_w <= 0 || p.p_h <= 0) p.p_w = p.p_h = 1; + p.rotate = d_video->codec->rotate; + p.stereo_in = d_video->codec->stereo_mode; + if (opts->video_rotate < 0) { p.rotate = 0; } else { diff --git a/video/decode/lavc.h b/video/decode/lavc.h index 810d7e393c..5795af3ecf 100644 --- a/video/decode/lavc.h +++ b/video/decode/lavc.h @@ -40,9 +40,6 @@ typedef struct lavc_ctx { bool intra_only; int framedrop_flags; - // For HDR side-data caching - float cached_sig_peak; - bool hw_probing; struct demux_packet **sent_packets; int num_sent_packets; diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 01c404106e..d146270062 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -49,10 +49,6 @@ #include "video/sws_utils.h" #include "video/out/vo.h" -#if LIBAVCODEC_VERSION_MICRO >= 100 -#include <libavutil/mastering_display_metadata.h> -#endif - #include "lavc.h" #if AVPALETTE_SIZE != MP_PALETTE_SIZE @@ -728,39 +724,6 @@ static void uninit_avctx(struct dec_video *vd) ctx->hw_probing = false; } -static void update_image_params(struct dec_video *vd, AVFrame *frame, - struct mp_image_params *params) -{ - vd_ffmpeg_ctx *ctx = vd->priv; - AVFrameSideData *sd; - -#if LIBAVCODEC_VERSION_MICRO >= 100 - // Get the content light metadata if available - sd = av_frame_get_side_data(frame, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); - if (sd) { - AVContentLightMetadata *clm = (AVContentLightMetadata *)sd->data; - params->color.sig_peak = clm->MaxCLL / MP_REF_WHITE; - } - - // Otherwise, try getting the mastering metadata if available - sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); - if (!params->color.sig_peak && sd) { - AVMasteringDisplayMetadata *mdm = (AVMasteringDisplayMetadata *)sd->data; - if (mdm->has_luminance) - params->color.sig_peak = av_q2d(mdm->max_luminance) / MP_REF_WHITE; - } -#endif - - if (params->color.sig_peak) { - ctx->cached_sig_peak = params->color.sig_peak; - } else { - params->color.sig_peak = ctx->cached_sig_peak; - } - - params->rotate = vd->codec->rotate; - params->stereo_in = vd->codec->stereo_mode; -} - static int init_generic_hwaccel(struct dec_video *vd, enum AVPixelFormat hw_fmt) { struct lavc_ctx *ctx = vd->priv; @@ -1174,8 +1137,6 @@ static bool decode_frame(struct dec_video *vd) mp_pts_from_av(ctx->pic->pkt_duration, &ctx->codec_timebase); #endif - update_image_params(vd, ctx->pic, &mpi->params); - av_frame_unref(ctx->pic); MP_TARRAY_APPEND(ctx, ctx->delay_queue, ctx->num_delay_queue, mpi); diff --git a/video/mp_image.c b/video/mp_image.c index 47ea115a90..6934ff4c58 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -26,6 +26,10 @@ #include <libavutil/rational.h> #include <libavcodec/avcodec.h> +#if LIBAVUTIL_VERSION_MICRO >= 100 +#include <libavutil/mastering_display_metadata.h> +#endif + #include "mpv_talloc.h" #include "config.h" @@ -872,6 +876,21 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *src) sd = av_frame_get_side_data(src, AV_FRAME_DATA_ICC_PROFILE); if (sd) dst->icc_profile = av_buffer_ref(sd->buf); + + // Get the content light metadata if available + sd = av_frame_get_side_data(src, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); + if (sd) { + AVContentLightMetadata *clm = (AVContentLightMetadata *)sd->data; + dst->params.color.sig_peak = clm->MaxCLL / MP_REF_WHITE; + } + + // Otherwise, try getting the mastering metadata if available + sd = av_frame_get_side_data(src, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + if (!dst->params.color.sig_peak && sd) { + AVMasteringDisplayMetadata *mdm = (AVMasteringDisplayMetadata *)sd->data; + if (mdm->has_luminance) + dst->params.color.sig_peak = av_q2d(mdm->max_luminance) / MP_REF_WHITE; + } #endif if (dst->hwctx) { |