mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec/mediacodec: add vp9 encoder using mediacodec
The only encoders avaliable using mediacodec were h264 and hevc. This patch adds the vp9 encoder. Signed-off-by: Samuel Mira <samuel.mira@qt.io<mailto:samuel.mira@qt.io>> Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
This commit is contained in:
parent
dd7e30724b
commit
139f3352ed
3
configure
vendored
3
configure
vendored
@ -3248,6 +3248,9 @@ vp8_v4l2m2m_decoder_deps="v4l2_m2m vp8_v4l2_m2m"
|
||||
vp8_v4l2m2m_encoder_deps="v4l2_m2m vp8_v4l2_m2m"
|
||||
vp9_cuvid_decoder_deps="cuvid"
|
||||
vp9_mediacodec_decoder_deps="mediacodec"
|
||||
vp9_mediacodec_decoder_extralibs="-landroid"
|
||||
vp9_mediacodec_encoder_deps="mediacodec"
|
||||
vp9_mediacodec_encoder_extralibs="-landroid"
|
||||
vp9_qsv_decoder_select="qsvdec"
|
||||
vp9_rkmpp_decoder_deps="rkmpp"
|
||||
vp9_vaapi_encoder_deps="VAEncPictureParameterBufferVP9"
|
||||
|
@ -774,6 +774,7 @@ OBJS-$(CONFIG_VP9_DECODER) += vp9.o vp9data.o vp9dsp.o vp9lpf.o vp9r
|
||||
vp9dsp_8bpp.o vp9dsp_10bpp.o vp9dsp_12bpp.o
|
||||
OBJS-$(CONFIG_VP9_CUVID_DECODER) += cuviddec.o
|
||||
OBJS-$(CONFIG_VP9_MEDIACODEC_DECODER) += mediacodecdec.o
|
||||
OBJS-$(CONFIG_VP9_MEDIACODEC_ENCODER) += mediacodecenc.o
|
||||
OBJS-$(CONFIG_VP9_RKMPP_DECODER) += rkmppdec.o
|
||||
OBJS-$(CONFIG_VP9_VAAPI_ENCODER) += vaapi_encode_vp9.o
|
||||
OBJS-$(CONFIG_VP9_QSV_ENCODER) += qsvenc_vp9.o
|
||||
|
@ -884,6 +884,7 @@ extern const FFCodec ff_vp8_v4l2m2m_encoder;
|
||||
extern const FFCodec ff_vp8_vaapi_encoder;
|
||||
extern const FFCodec ff_vp9_cuvid_decoder;
|
||||
extern const FFCodec ff_vp9_mediacodec_decoder;
|
||||
extern const FFCodec ff_vp9_mediacodec_encoder;
|
||||
extern const FFCodec ff_vp9_qsv_decoder;
|
||||
extern const FFCodec ff_vp9_vaapi_encoder;
|
||||
extern const FFCodec ff_vp9_qsv_encoder;
|
||||
|
@ -319,10 +319,23 @@ int ff_AMediaCodecProfile_getProfileFromAVCodecContext(AVCodecContext *avctx)
|
||||
static const int HEVCProfileMain10HDR10 = 0x1000;
|
||||
static const int HEVCProfileMain10HDR10Plus = 0x2000;
|
||||
|
||||
static const int VP9Profile0 = 0x01;
|
||||
static const int VP9Profile1 = 0x02;
|
||||
static const int VP9Profile2 = 0x04;
|
||||
static const int VP9Profile3 = 0x08;
|
||||
static const int VP9Profile2HDR = 0x1000;
|
||||
static const int VP9Profile3HDR = 0x2000;
|
||||
static const int VP9Profile2HDR10Plus = 0x4000;
|
||||
static const int VP9Profile3HDR10Plus = 0x8000;
|
||||
|
||||
// Unused yet.
|
||||
(void)AVCProfileConstrainedHigh;
|
||||
(void)HEVCProfileMain10HDR10;
|
||||
(void)HEVCProfileMain10HDR10Plus;
|
||||
(void)VP9Profile2HDR;
|
||||
(void)VP9Profile3HDR;
|
||||
(void)VP9Profile2HDR10Plus;
|
||||
(void)VP9Profile3HDR10Plus;
|
||||
|
||||
if (avctx->codec_id == AV_CODEC_ID_H264) {
|
||||
switch(avctx->profile) {
|
||||
@ -357,6 +370,17 @@ int ff_AMediaCodecProfile_getProfileFromAVCodecContext(AVCodecContext *avctx)
|
||||
case FF_PROFILE_HEVC_MAIN_10:
|
||||
return HEVCProfileMain10;
|
||||
}
|
||||
} else if (avctx->codec_id == AV_CODEC_ID_VP9) {
|
||||
switch (avctx->profile) {
|
||||
case FF_PROFILE_VP9_0:
|
||||
return VP9Profile0;
|
||||
case FF_PROFILE_VP9_1:
|
||||
return VP9Profile1;
|
||||
case FF_PROFILE_VP9_2:
|
||||
return VP9Profile2;
|
||||
case FF_PROFILE_VP9_3:
|
||||
return VP9Profile3;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -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_VP9:
|
||||
codec_mime = "video/x-vnd.on2.vp9";
|
||||
break;
|
||||
default:
|
||||
av_assert0(0);
|
||||
}
|
||||
@ -764,3 +767,61 @@ static const AVOption hevc_options[] = {
|
||||
DECLARE_MEDIACODEC_ENCODER(hevc, "H.265", AV_CODEC_ID_HEVC)
|
||||
|
||||
#endif // CONFIG_HEVC_MEDIACODEC_ENCODER
|
||||
|
||||
#if CONFIG_VP9_MEDIACODEC_ENCODER
|
||||
|
||||
enum MediaCodecVP9Level {
|
||||
VP9Level1 = 0x1,
|
||||
VP9Level11 = 0x2,
|
||||
VP9Level2 = 0x4,
|
||||
VP9Level21 = 0x8,
|
||||
VP9Level3 = 0x10,
|
||||
VP9Level31 = 0x20,
|
||||
VP9Level4 = 0x40,
|
||||
VP9Level41 = 0x80,
|
||||
VP9Level5 = 0x100,
|
||||
VP9Level51 = 0x200,
|
||||
VP9Level52 = 0x400,
|
||||
VP9Level6 = 0x800,
|
||||
VP9Level61 = 0x1000,
|
||||
VP9Level62 = 0x2000,
|
||||
};
|
||||
|
||||
static const AVOption vp9_options[] = {
|
||||
COMMON_OPTION
|
||||
{ "level", "Specify tier and level",
|
||||
OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, "level" },
|
||||
{ "1", "Level 1",
|
||||
0, AV_OPT_TYPE_CONST, { .i64 = VP9Level1 }, 0, 0, VE, "level" },
|
||||
{ "1.1", "Level 1.1",
|
||||
0, AV_OPT_TYPE_CONST, { .i64 = VP9Level11 }, 0, 0, VE, "level" },
|
||||
{ "2", "Level 2",
|
||||
0, AV_OPT_TYPE_CONST, { .i64 = VP9Level2 }, 0, 0, VE, "level" },
|
||||
{ "2.1", "Level 2.1",
|
||||
0, AV_OPT_TYPE_CONST, { .i64 = VP9Level21 }, 0, 0, VE, "level" },
|
||||
{ "3", "Level 3",
|
||||
0, AV_OPT_TYPE_CONST, { .i64 = VP9Level3 }, 0, 0, VE, "level" },
|
||||
{ "3.1", "Level 3.1",
|
||||
0, AV_OPT_TYPE_CONST, { .i64 = VP9Level31 }, 0, 0, VE, "level" },
|
||||
{ "4", "Level 4",
|
||||
0, AV_OPT_TYPE_CONST, { .i64 = VP9Level4 }, 0, 0, VE, "level" },
|
||||
{ "4.1", "Level 4.1",
|
||||
0, AV_OPT_TYPE_CONST, { .i64 = VP9Level41 }, 0, 0, VE, "level" },
|
||||
{ "5", "Level 5",
|
||||
0, AV_OPT_TYPE_CONST, { .i64 = VP9Level5 }, 0, 0, VE, "level" },
|
||||
{ "5.1", "Level 5.1",
|
||||
0, AV_OPT_TYPE_CONST, { .i64 = VP9Level51 }, 0, 0, VE, "level" },
|
||||
{ "5.2", "Level 5.2",
|
||||
0, AV_OPT_TYPE_CONST, { .i64 = VP9Level52 }, 0, 0, VE, "level" },
|
||||
{ "6", "Level 6",
|
||||
0, AV_OPT_TYPE_CONST, { .i64 = VP9Level6 }, 0, 0, VE, "level" },
|
||||
{ "6.1", "Level 4.1",
|
||||
0, AV_OPT_TYPE_CONST, { .i64 = VP9Level61 }, 0, 0, VE, "level" },
|
||||
{ "6.2", "Level 6.2",
|
||||
0, AV_OPT_TYPE_CONST, { .i64 = VP9Level62 }, 0, 0, VE, "level" },
|
||||
{ NULL, }
|
||||
};
|
||||
|
||||
DECLARE_MEDIACODEC_ENCODER(vp9, "VP9", AV_CODEC_ID_VP9)
|
||||
|
||||
#endif // CONFIG_VP9_MEDIACODEC_ENCODER
|
||||
|
@ -29,8 +29,8 @@
|
||||
|
||||
#include "version_major.h"
|
||||
|
||||
#define LIBAVCODEC_VERSION_MINOR 7
|
||||
#define LIBAVCODEC_VERSION_MICRO 101
|
||||
#define LIBAVCODEC_VERSION_MINOR 8
|
||||
#define LIBAVCODEC_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
|
Loading…
Reference in New Issue
Block a user