[FFmpeg-devel] [PATCH] libaomdec: add row_mt option
Tristan Matthews
tmatth at videolan.org
Wed Sep 26 06:38:44 EEST 2018
Partially fixes #7456
---
libavcodec/libaomdec.c | 62 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c
index 2530c9f76b..15cda2940a 100644
--- a/libavcodec/libaomdec.c
+++ b/libavcodec/libaomdec.c
@@ -23,20 +23,63 @@
* AV1 decoder support via libaom
*/
+#define AOM_DISABLE_CTRL_TYPECHECKS 1
#include <aom/aom_decoder.h>
#include <aom/aomdx.h>
#include "libavutil/common.h"
#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
#include "avcodec.h"
#include "internal.h"
#include "profiles.h"
typedef struct AV1DecodeContext {
+ AVClass *class;
struct aom_codec_ctx decoder;
+ int row_mt;
} AV1DecodeContext;
+static const char *const ctlidstr[] = {
+ [AV1D_SET_ROW_MT] = "AV1D_SET_ROW_MT",
+};
+
+
+static av_cold void log_decoder_error(AVCodecContext *avctx, const char *desc)
+{
+ AV1DecodeContext *ctx = avctx->priv_data;
+ const char *error = aom_codec_error(&ctx->decoder);
+ const char *detail = aom_codec_error_detail(&ctx->decoder);
+
+ av_log(avctx, AV_LOG_ERROR, "%s: %s\n", desc, error);
+ if (detail)
+ av_log(avctx, AV_LOG_ERROR, " Additional information: %s\n", detail);
+}
+
+static av_cold int codecctl_int(AVCodecContext *avctx,
+ enum aom_dec_control_id id, int val)
+{
+ AV1DecodeContext *ctx = avctx->priv_data;
+ char buf[80];
+ int width = -30;
+ int res;
+
+ snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
+ av_log(avctx, AV_LOG_DEBUG, " %*s%d\n", width, buf, val);
+
+ res = aom_codec_control(&ctx->decoder, id, val);
+ if (res != AOM_CODEC_OK) {
+ snprintf(buf, sizeof(buf), "Failed to set %s codec control",
+ ctlidstr[id]);
+ log_decoder_error(avctx, buf);
+ return AVERROR(EINVAL);
+ }
+
+ return 0;
+}
+
+
static av_cold int aom_init(AVCodecContext *avctx,
const struct aom_codec_iface *iface)
{
@@ -56,6 +99,10 @@ static av_cold int aom_init(AVCodecContext *avctx,
return AVERROR(EINVAL);
}
+ // codec control failures are currently treated only as warnings
+ av_log(avctx, AV_LOG_DEBUG, "aom_codec_control\n");
+ codecctl_int(avctx, AV1D_SET_ROW_MT, ctx->row_mt);
+
return 0;
}
@@ -220,6 +267,20 @@ static av_cold int av1_init(AVCodecContext *avctx)
return aom_init(avctx, &aom_codec_av1_dx_algo);
}
+#define OFFSET(x) offsetof(AV1DecodeContext, x)
+#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
+static const AVOption options[] = {
+ { "row-mt", "Enable row-based multithreading", OFFSET(row_mt), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, VD},
+ { NULL },
+};
+
+static const AVClass class_aom = {
+ .class_name = "libaom-av1 decoder",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_libaom_av1_decoder = {
.name = "libaom-av1",
.long_name = NULL_IF_CONFIG_SMALL("libaom AV1"),
@@ -231,5 +292,6 @@ AVCodec ff_libaom_av1_decoder = {
.decode = aom_decode,
.capabilities = AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_DR1,
.profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
+ .priv_class = &class_aom,
.wrapper_name = "libaom",
};
--
2.17.1
More information about the ffmpeg-devel
mailing list