]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/libvpx.c
Merge commit 'a8a90906fb0ad0f8d3c68a97f182528ee3b5198c'
[ffmpeg] / libavcodec / libvpx.c
index 5d2989360227e689cb6e4eb71ac395aee96b0aab..e0f9df3caa47fd4f947cedd45806a6e0148352ea 100644 (file)
  */
 
 #include <vpx/vpx_codec.h>
-
 #include "libvpx.h"
+#include "config.h"
+
+#if CONFIG_LIBVPX_VP9_ENCODER
+#include <vpx/vpx_encoder.h>
+#include <vpx/vp8cx.h>
+#endif
+
+static const enum AVPixelFormat vp9_pix_fmts_def[] = {
+    AV_PIX_FMT_YUV420P,
+    AV_PIX_FMT_NONE
+};
+
+#if CONFIG_LIBVPX_VP9_ENCODER
+static const enum AVPixelFormat vp9_pix_fmts_highcol[] = {
+    AV_PIX_FMT_YUV420P,
+    AV_PIX_FMT_YUV422P,
+    AV_PIX_FMT_YUV440P,
+    AV_PIX_FMT_YUV444P,
+    AV_PIX_FMT_NONE
+};
+
+static const enum AVPixelFormat vp9_pix_fmts_highbd[] = {
+    AV_PIX_FMT_YUV420P,
+    AV_PIX_FMT_YUV422P,
+    AV_PIX_FMT_YUV440P,
+    AV_PIX_FMT_YUV444P,
+    AV_PIX_FMT_YUV420P10LE,
+    AV_PIX_FMT_YUV422P10LE,
+    AV_PIX_FMT_YUV440P10LE,
+    AV_PIX_FMT_YUV444P10LE,
+    AV_PIX_FMT_YUV420P12LE,
+    AV_PIX_FMT_YUV422P12LE,
+    AV_PIX_FMT_YUV440P12LE,
+    AV_PIX_FMT_YUV444P12LE,
+    AV_PIX_FMT_NONE
+};
+#endif
 
 av_cold void ff_vp9_init_static(AVCodec *codec)
 {
     if (    vpx_codec_version_major() < 1
         || (vpx_codec_version_major() == 1 && vpx_codec_version_minor() < 3))
         codec->capabilities |= CODEC_CAP_EXPERIMENTAL;
+    codec->pix_fmts = vp9_pix_fmts_def;
+#if CONFIG_LIBVPX_VP9_ENCODER
+    if (    vpx_codec_version_major() > 1
+        || (vpx_codec_version_major() == 1 && vpx_codec_version_minor() >= 4)) {
+#ifdef VPX_CODEC_CAP_HIGHBITDEPTH
+        vpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx());
+        if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH)
+            codec->pix_fmts = vp9_pix_fmts_highbd;
+        else
+#endif
+            codec->pix_fmts = vp9_pix_fmts_highcol;
+    }
+#endif
 }