[FFmpeg-cvslog] swscale: Introduce a helper to identify semi-planar formats

Philip Langdale git at videolan.org
Sun Mar 4 01:25:26 EET 2018


ffmpeg | branch: master | Philip Langdale <philipl at overt.org> | Fri Mar  2 09:09:05 2018 -0800| [dd3f1e3a1186ac2cd3d4ce71944626a2c3f200f1] | committer: Philip Langdale

swscale: Introduce a helper to identify semi-planar formats

This cleans up the ever-more-unreadable list of semi-planar
exclusions for selecting the planar copy wrapper.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dd3f1e3a1186ac2cd3d4ce71944626a2c3f200f1
---

 libswscale/swscale_internal.h | 11 +++++++++++
 libswscale/swscale_unscaled.c |  7 +------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 0f51df95d7..c9120d8f5f 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -676,6 +676,17 @@ static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
     return ((desc->flags & AV_PIX_FMT_FLAG_PLANAR) && isYUV(pix_fmt));
 }
 
+/*
+ * Identity semi-planar YUV formats. Specifically, those are YUV formats
+ * where the second and third components (U & V) are on the same plane.
+ */
+static av_always_inline int isSemiPlanarYUV(enum AVPixelFormat pix_fmt)
+{
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
+    av_assert0(desc);
+    return (isPlanarYUV(pix_fmt) && desc->comp[1].plane == desc->comp[2].plane);
+}
+
 static av_always_inline int isRGB(enum AVPixelFormat pix_fmt)
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index 766c9b4872..13f9cd83e3 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -1930,12 +1930,7 @@ void ff_get_unscaled_swscale(SwsContext *c)
         (isPlanarYUV(srcFormat) && isPlanarYUV(dstFormat) &&
          c->chrDstHSubSample == c->chrSrcHSubSample &&
          c->chrDstVSubSample == c->chrSrcVSubSample &&
-         dstFormat != AV_PIX_FMT_NV12 && dstFormat != AV_PIX_FMT_NV21 &&
-         dstFormat != AV_PIX_FMT_P010LE && dstFormat != AV_PIX_FMT_P010BE &&
-         dstFormat != AV_PIX_FMT_P016LE && dstFormat != AV_PIX_FMT_P016BE &&
-         srcFormat != AV_PIX_FMT_NV12 && srcFormat != AV_PIX_FMT_NV21 &&
-         srcFormat != AV_PIX_FMT_P010LE && srcFormat != AV_PIX_FMT_P010BE &&
-         srcFormat != AV_PIX_FMT_P016LE && srcFormat != AV_PIX_FMT_P016BE))
+         !isSemiPlanarYUV(srcFormat) && !isSemiPlanarYUV(dstFormat)))
     {
         if (isPacked(c->srcFormat))
             c->swscale = packedCopyWrapper;



More information about the ffmpeg-cvslog mailing list