From 50fc14843611f9b772bff8f2d7f96b67b3c5929e Mon Sep 17 00:00:00 2001
From: Tristan Matthews <le.businessman@gmail.com>
Date: Mon, 23 Sep 2013 12:01:23 -0400
Subject: [PATCH] * #30480: video: backport av_pix_fmt_desc_get

---
 daemon/src/video/libav_deps.h   | 8 ++++++++
 daemon/src/video/video_base.cpp | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/daemon/src/video/libav_deps.h b/daemon/src/video/libav_deps.h
index 0fe9f03e6d..ccfaaff168 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 6b1ad60826..0e0116d087 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);
 
-- 
GitLab