diff --git a/daemon/src/video/libav_deps.h b/daemon/src/video/libav_deps.h index 0fe9f03e6d1712b5912a8ebf65928e2c1f7b5f56..ccfaaff168d3ea845218646613083b1d27d655fa 100644 --- a/daemon/src/video/libav_deps.h +++ b/daemon/src/video/libav_deps.h @@ -75,6 +75,14 @@ extern "C" { #if !LIBAVUTIL_VERSION_CHECK(51, 42, 0, 74, 100) && !defined(FF_API_PIX_FMT) #define AVPixelFormat PixelFormat #define PIXEL_FORMAT(FMT) PIX_FMT_ ## FMT + +static inline const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt) +{ + if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB) + return NULL; + return &av_pix_fmt_descriptors[pix_fmt]; +} + #else #define PIXEL_FORMAT(FMT) AV_PIX_FMT_ ## FMT #endif diff --git a/daemon/src/video/video_base.cpp b/daemon/src/video/video_base.cpp index 6b1ad60826d7604a2026b9a92a01c5a3983584ef..0e0116d08767a08e5d647d9fb24fa3f10a480df2 100644 --- a/daemon/src/video/video_base.cpp +++ b/daemon/src/video/video_base.cpp @@ -220,6 +220,10 @@ static int flipHorizontal(AVFrame *frame) uint8_t *inrow, *outrow; int step, hsub, vsub; const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get((AVPixelFormat) libav_utils::libav_pixel_format(frame->format)); + if (!pix_desc) { + ERROR("Could not get pixel descriptor"); + return -1; + } int max_step[4]; ///< max pixel step for each plane, expressed as a number of bytes av_image_fill_max_pixsteps(max_step, NULL, pix_desc);