]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/libutvideoenc.cpp
Merge commit '34c9eba982c75196392a3b0b245dd34297c4511d'
[ffmpeg] / libavcodec / libutvideoenc.cpp
index 87462470e211c063b43837eb2cd4e84bbaeb82bd..d5dfef938a1773381d890844bc02139bc68461b9 100644 (file)
@@ -26,7 +26,9 @@
  */
 
 extern "C" {
+#include "libavutil/opt.h"
 #include "libavutil/avassert.h"
+#include "libavutil/imgutils.h"
 #include "avcodec.h"
 #include "internal.h"
 }
@@ -72,13 +74,20 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
         return AVERROR(EINVAL);
     }
 
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
+    if (avctx->prediction_method)
+        utv->pred = avctx->prediction_method;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
     /* Check before we alloc anything */
-    if (avctx->prediction_method != 0 && avctx->prediction_method != 2) {
+    if (utv->pred != 0 && utv->pred != 2) {
         av_log(avctx, AV_LOG_ERROR, "Invalid prediction method.\n");
         return AVERROR(EINVAL);
     }
 
-    flags = ((avctx->prediction_method + 1) << 8) | (avctx->thread_count - 1);
+    flags = ((utv->pred + 1) << 8) | (avctx->thread_count - 1);
 
     avctx->priv_data = utv;
 
@@ -94,7 +103,7 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
      * We use this buffer to hold the data that Ut Video returns,
      * since we cannot decode planes separately with it.
      */
-    ret = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
+    ret = av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1);
     if (ret < 0) {
         av_free(info);
         return ret;
@@ -217,6 +226,29 @@ static av_cold int utvideo_encode_close(AVCodecContext *avctx)
     return 0;
 }
 
+#define OFFSET(x) offsetof(UtVideoContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption options[] = {
+    { "pred", "Prediction method", OFFSET(pred), AV_OPT_TYPE_INT, 0, 0, 2, VE, "pred" },
+    { "left",   NULL, 0, AV_OPT_TYPE_CONST, 0, INT_MIN, INT_MAX, VE, "pred" },
+    { "median",   NULL, 0, AV_OPT_TYPE_CONST, 2, INT_MIN, INT_MAX, VE, "pred" },
+    { NULL },
+};
+
+static const AVClass utvideo_class = {
+    "libutvideo",
+    av_default_item_name,
+    options,
+    LIBAVUTIL_VERSION_INT,
+    0,
+    0,
+    NULL,
+    NULL,
+    AV_CLASS_CATEGORY_NA,
+    NULL,
+    NULL,
+};
+
 AVCodec ff_libutvideo_encoder = {
     "libutvideo",
     NULL_IF_CONFIG_SMALL("Ut Video"),
@@ -232,7 +264,7 @@ AVCodec ff_libutvideo_encoder = {
     NULL, /* sample_fmts */
     NULL, /* channel_layouts */
     0,    /* max_lowres */
-    NULL, /* priv_class */
+    &utvideo_class, /* priv_class */
     NULL, /* profiles */
     sizeof(UtVideoContext),
     NULL, /* next */