summaryrefslogtreecommitdiff
path: root/libavcodec/utvideoenc.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2015-11-09 03:15:06 +0100
committerVittorio Giovara <vittorio.giovara@gmail.com>2016-01-21 15:33:19 -0500
commit2862b63783b5556f7f3fb2d097629bc6879f833a (patch)
tree990909a954f2ce1a6cd5ed5f7e94c305426b5b66 /libavcodec/utvideoenc.c
parent243df1351d2d928caa084a5704ed783f0b83f072 (diff)
downloadffmpeg-2862b63783b5556f7f3fb2d097629bc6879f833a.tar.gz
lavc: Move prediction_method to codec private options
This options is only used by huffyuv, ffvhuv, jpegls, mjpeg, mpegvideoenc, png, utvideo. It is a very codec-specific options, so deprecate the global variant. Set proper limits to the maximum allowed values, and update utvideoenc tests to use the new option name. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavcodec/utvideoenc.c')
-rw-r--r--libavcodec/utvideoenc.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
index 9af0f66a71..7fb838e841 100644
--- a/libavcodec/utvideoenc.c
+++ b/libavcodec/utvideoenc.c
@@ -26,6 +26,8 @@
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+
#include "avcodec.h"
#include "internal.h"
#include "bswapdsp.h"
@@ -111,6 +113,8 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
ff_bswapdsp_init(&c->bdsp);
ff_huffyuvencdsp_init(&c->hdsp);
+#if FF_API_PRIVATE_OPT
+FF_DISABLE_DEPRECATION_WARNINGS
/* Check the prediction method, and error out if unsupported */
if (avctx->prediction_method < 0 || avctx->prediction_method > 4) {
av_log(avctx, AV_LOG_WARNING,
@@ -126,7 +130,10 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
}
/* Convert from libavcodec prediction type to Ut Video's */
- c->frame_pred = ff_ut_pred_order[avctx->prediction_method];
+ if (avctx->prediction_method)
+ c->frame_pred = ff_ut_pred_order[avctx->prediction_method];
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (c->frame_pred == PRED_GRADIENT) {
av_log(avctx, AV_LOG_ERROR, "Gradient prediction is not supported.\n");
@@ -631,12 +638,32 @@ FF_ENABLE_DEPRECATION_WARNINGS
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(frame_pred), AV_OPT_TYPE_INT, { .i64 = PRED_LEFT }, PRED_NONE, PRED_MEDIAN, VE, "pred" },
+ { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRED_NONE }, INT_MIN, INT_MAX, VE, "pred" },
+ { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRED_LEFT }, INT_MIN, INT_MAX, VE, "pred" },
+ { "gradient", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRED_GRADIENT }, INT_MIN, INT_MAX, VE, "pred" },
+ { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRED_MEDIAN }, INT_MIN, INT_MAX, VE, "pred" },
+
+ { NULL},
+};
+
+static const AVClass utvideo_class = {
+ .class_name = "utvideo",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_utvideo_encoder = {
.name = "utvideo",
.long_name = NULL_IF_CONFIG_SMALL("Ut Video"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_UTVIDEO,
.priv_data_size = sizeof(UtvideoContext),
+ .priv_class = &utvideo_class,
.init = utvideo_encode_init,
.encode2 = utvideo_encode_frame,
.close = utvideo_encode_close,