From 416fd1b43b50a8407cf7263b70daf1e0cbdc0fe9 Mon Sep 17 00:00:00 2001 From: Samuel Mira Date: Wed, 19 Apr 2023 23:29:18 +0300 Subject: [PATCH] avcodec/mediacodec: Add VP8 encoder Connected FFmpeg to Mediacodec VP8 encoder. Signed-off-by: Samuel Mira Signed-off-by: Zhao Zhili --- configure | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/mediacodecenc.c | 31 +++++++++++++++++++++++++++++++ libavcodec/version.h | 2 +- 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 0a60deac65..a54398c57f 100755 --- a/configure +++ b/configure @@ -3240,6 +3240,7 @@ vc1_qsv_decoder_select="qsvdec" vc1_v4l2m2m_decoder_deps="v4l2_m2m vc1_v4l2_m2m" vp8_cuvid_decoder_deps="cuvid" vp8_mediacodec_decoder_deps="mediacodec" +vp8_mediacodec_encoder_deps="mediacodec" vp8_qsv_decoder_select="qsvdec" vp8_rkmpp_decoder_deps="rkmpp" vp8_vaapi_encoder_deps="VAEncPictureParameterBufferVP8" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 2288c6c2d7..9c38240025 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -767,6 +767,7 @@ OBJS-$(CONFIG_VP7_DECODER) += vp8.o vp8data.o vpx_rac.o OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp8data.o vpx_rac.o OBJS-$(CONFIG_VP8_CUVID_DECODER) += cuviddec.o OBJS-$(CONFIG_VP8_MEDIACODEC_DECODER) += mediacodecdec.o +OBJS-$(CONFIG_VP8_MEDIACODEC_ENCODER) += mediacodecenc.o OBJS-$(CONFIG_VP8_QSV_DECODER) += qsvdec.o OBJS-$(CONFIG_VP8_RKMPP_DECODER) += rkmppdec.o OBJS-$(CONFIG_VP8_VAAPI_ENCODER) += vaapi_encode_vp8.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index f583aad860..184bb8521f 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -881,6 +881,7 @@ extern const FFCodec ff_prores_videotoolbox_encoder; extern const FFCodec ff_vc1_cuvid_decoder; extern const FFCodec ff_vp8_cuvid_decoder; extern const FFCodec ff_vp8_mediacodec_decoder; +extern const FFCodec ff_vp8_mediacodec_encoder; extern const FFCodec ff_vp8_qsv_decoder; extern const FFCodec ff_vp8_v4l2m2m_encoder; extern const FFCodec ff_vp8_vaapi_encoder; diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c index 2b7bef444e..d23745c1c1 100644 --- a/libavcodec/mediacodecenc.c +++ b/libavcodec/mediacodecenc.c @@ -164,6 +164,9 @@ static av_cold int mediacodec_init(AVCodecContext *avctx) case AV_CODEC_ID_HEVC: codec_mime = "video/hevc"; break; + case AV_CODEC_ID_VP8: + codec_mime = "video/x-vnd.on2.vp8"; + break; case AV_CODEC_ID_VP9: codec_mime = "video/x-vnd.on2.vp9"; break; @@ -778,6 +781,34 @@ DECLARE_MEDIACODEC_ENCODER(hevc, "H.265", AV_CODEC_ID_HEVC) #endif // CONFIG_HEVC_MEDIACODEC_ENCODER +#if CONFIG_VP8_MEDIACODEC_ENCODER + +enum MediaCodecVP8Level { + VP8Level_Version0 = 0x01, + VP8Level_Version1 = 0x02, + VP8Level_Version2 = 0x04, + VP8Level_Version3 = 0x08, +}; + +static const AVOption vp8_options[] = { + COMMON_OPTION + { "level", "Specify tier and level", + OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, "level" }, + { "V0", "Level Version 0", + 0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version0 }, 0, 0, VE, "level" }, + { "V1", "Level Version 1", + 0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version1 }, 0, 0, VE, "level" }, + { "V2", "Level Version 2", + 0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version2 }, 0, 0, VE, "level" }, + { "V3", "Level Version 3", + 0, AV_OPT_TYPE_CONST, { .i64 = VP8Level_Version3 }, 0, 0, VE, "level" }, + { NULL, } +}; + +DECLARE_MEDIACODEC_ENCODER(vp8, "VP8", AV_CODEC_ID_VP8) + +#endif // CONFIG_VP8_MEDIACODEC_ENCODER + #if CONFIG_VP9_MEDIACODEC_ENCODER enum MediaCodecVP9Level { diff --git a/libavcodec/version.h b/libavcodec/version.h index 755c90bbc1..7531c6c42a 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 13 +#define LIBAVCODEC_VERSION_MINOR 14 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \