This patch will add MPEG4 encoder using Android Mediacodec
Unified · Split
| @@ -3228,6 +3228,8 @@ mpeg2_v4l2m2m_decoder_deps="v4l2_m2m mpeg2_v4l2_m2m" · 3227 unmodified lines | ||
| 3228 | 3228 | mpeg4_crystalhd_decoder_select="crystalhd" |
| 3229 | 3229 | mpeg4_cuvid_decoder_deps="cuvid" |
| 3230 | 3230 | mpeg4_mediacodec_decoder_deps="mediacodec" |
| 3231 | +mpeg4_mediacodec_encoder_deps="mediacodec" | |
| 3232 | +mpeg4_mediacodec_encoder_extralibs="-landroid" | |
| 3231 | 3233 | mpeg4_mmal_decoder_deps="mmal" |
| 3232 | 3234 | mpeg4_omx_encoder_deps="omx" |
| 3233 | 3235 | mpeg4_v4l2m2m_decoder_deps="v4l2_m2m mpeg4_v4l2_m2m" |
| @@ -542,6 +542,7 @@ OBJS-$(CONFIG_MPEG4_DECODER) += mpeg4videodsp.o xvididct.o · 541 unmodified lines | ||
| 542 | 542 | OBJS-$(CONFIG_MPEG4_ENCODER) += mpeg4videoenc.o |
| 543 | 543 | OBJS-$(CONFIG_MPEG4_CUVID_DECODER) += cuviddec.o |
| 544 | 544 | OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o |
| 545 | +OBJS-$(CONFIG_MPEG4_MEDIACODEC_ENCODER) += mediacodecenc.o | |
| 545 | 546 | OBJS-$(CONFIG_MPEG4_OMX_ENCODER) += omx.o |
| 546 | 547 | OBJS-$(CONFIG_MPEG4_V4L2M2M_DECODER) += v4l2_m2m_dec.o |
| 547 | 548 | OBJS-$(CONFIG_MPEG4_V4L2M2M_ENCODER) += v4l2_m2m_enc.o |
| @@ -873,6 +873,7 @@ extern const FFCodec ff_mpeg2_qsv_encoder; · 872 unmodified lines | ||
| 873 | 873 | extern const FFCodec ff_mpeg2_vaapi_encoder; |
| 874 | 874 | extern const FFCodec ff_mpeg4_cuvid_decoder; |
| 875 | 875 | extern const FFCodec ff_mpeg4_mediacodec_decoder; |
| 876 | +extern const FFCodec ff_mpeg4_mediacodec_encoder; | |
| 876 | 877 | extern const FFCodec ff_mpeg4_omx_encoder; |
| 877 | 878 | extern const FFCodec ff_mpeg4_v4l2m2m_encoder; |
| 878 | 879 | extern const FFCodec ff_prores_videotoolbox_encoder; |
| @@ -328,6 +328,23 @@ int ff_AMediaCodecProfile_getProfileFromAVCodecContext(AVCodecContext *avctx) · 327 unmodified lines | ||
| 328 | 328 | static const int VP9Profile2HDR10Plus = 0x4000; |
| 329 | 329 | static const int VP9Profile3HDR10Plus = 0x8000; |
| 330 | 330 | |
| 331 | + static const int MPEG4ProfileSimple = 0x01; | |
| 332 | + static const int MPEG4ProfileSimpleScalable = 0x02; | |
| 333 | + static const int MPEG4ProfileCore = 0x04; | |
| 334 | + static const int MPEG4ProfileMain = 0x08; | |
| 335 | + static const int MPEG4ProfileNbit = 0x10; | |
| 336 | + static const int MPEG4ProfileScalableTexture = 0x20; | |
| 337 | + static const int MPEG4ProfileSimpleFBA = 0x80; | |
| 338 | + static const int MPEG4ProfileSimpleFace = 0x40; | |
| 339 | + static const int MPEG4ProfileBasicAnimated = 0x100; | |
| 340 | + static const int MPEG4ProfileHybrid = 0x200; | |
| 341 | + static const int MPEG4ProfileAdvancedRealTime = 0x400; | |
| 342 | + static const int MPEG4ProfileCoreScalable = 0x800; | |
| 343 | + static const int MPEG4ProfileAdvancedCoding = 0x1000; | |
| 344 | + static const int MPEG4ProfileAdvancedCore = 0x2000; | |
| 345 | + static const int MPEG4ProfileAdvancedScalable = 0x4000; | |
| 346 | + static const int MPEG4ProfileAdvancedSimple = 0x8000; | |
| 347 | + | |
| 331 | 348 | // Unused yet. |
| 332 | 349 | (void)AVCProfileConstrainedHigh; |
| 333 | 350 | (void)HEVCProfileMain10HDR10; |
| @@ -381,6 +398,44 @@ int ff_AMediaCodecProfile_getProfileFromAVCodecContext(AVCodecContext *avctx) · 47 unmodified lines | ||
| 381 | 398 | case FF_PROFILE_VP9_3: |
| 382 | 399 | return VP9Profile3; |
| 383 | 400 | } |
| 401 | + } else if(avctx->codec_id == AV_CODEC_ID_MPEG4) { | |
| 402 | + switch (avctx->profile) | |
| 403 | + { | |
| 404 | + case FF_PROFILE_MPEG4_SIMPLE: | |
| 405 | + return MPEG4ProfileSimple; | |
| 406 | + case FF_PROFILE_MPEG4_SIMPLE_SCALABLE: | |
| 407 | + return MPEG4ProfileSimpleScalable; | |
| 408 | + case FF_PROFILE_MPEG4_CORE: | |
| 409 | + return MPEG4ProfileCore; | |
| 410 | + case FF_PROFILE_MPEG4_MAIN: | |
| 411 | + return MPEG4ProfileMain; | |
| 412 | + case FF_PROFILE_MPEG4_N_BIT: | |
| 413 | + return MPEG4ProfileNbit; | |
| 414 | + case FF_PROFILE_MPEG4_SCALABLE_TEXTURE: | |
| 415 | + return MPEG4ProfileScalableTexture; | |
| 416 | + case FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION: | |
| 417 | + return MPEG4ProfileSimpleFBA; | |
| 418 | + case FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE: | |
| 419 | + return MPEG4ProfileBasicAnimated; | |
| 420 | + case FF_PROFILE_MPEG4_HYBRID: | |
| 421 | + return MPEG4ProfileHybrid; | |
| 422 | + case FF_PROFILE_MPEG4_ADVANCED_REAL_TIME: | |
| 423 | + return MPEG4ProfileAdvancedRealTime; | |
| 424 | + case FF_PROFILE_MPEG4_CORE_SCALABLE: | |
| 425 | + return MPEG4ProfileCoreScalable; | |
| 426 | + case FF_PROFILE_MPEG4_ADVANCED_CODING: | |
| 427 | + return MPEG4ProfileAdvancedCoding; | |
| 428 | + case FF_PROFILE_MPEG4_ADVANCED_CORE: | |
| 429 | + return MPEG4ProfileAdvancedCore; | |
| 430 | + case FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE: | |
| 431 | + return MPEG4ProfileAdvancedScalable; | |
| 432 | + case FF_PROFILE_MPEG4_ADVANCED_SIMPLE: | |
| 433 | + return MPEG4ProfileAdvancedSimple; | |
| 434 | + case FF_PROFILE_MPEG4_SIMPLE_STUDIO: | |
| 435 | + // Studio profiles are not supported by mediacodec. | |
| 436 | + default: | |
| 437 | + break; | |
| 438 | + } | |
| 384 | 439 | } |
| 385 | 440 | |
| 386 | 441 | return -1; |
| @@ -167,6 +167,9 @@ static av_cold int mediacodec_init(AVCodecContext *avctx) · 166 unmodified lines | ||
| 167 | 167 | case AV_CODEC_ID_VP9: |
| 168 | 168 | codec_mime = "video/x-vnd.on2.vp9"; |
| 169 | 169 | break; |
| 170 | + case AV_CODEC_ID_MPEG4: | |
| 171 | + codec_mime = "video/mp4v-es"; | |
| 172 | + break; | |
| 170 | 173 | default: |
| 171 | 174 | av_assert0(0); |
| 172 | 175 | } |
| @@ -825,3 +828,49 @@ static const AVOption vp9_options[] = { · 652 unmodified lines | ||
| 825 | 828 | DECLARE_MEDIACODEC_ENCODER(vp9, "VP9", AV_CODEC_ID_VP9) |
| 826 | 829 | |
| 827 | 830 | #endif // CONFIG_VP9_MEDIACODEC_ENCODER |
| 831 | + | |
| 832 | +#if CONFIG_MPEG4_MEDIACODEC_ENCODER | |
| 833 | + | |
| 834 | +enum MediaCodecMpeg4Level { | |
| 835 | + MPEG4Level0 = 0x01, | |
| 836 | + MPEG4Level0b = 0x02, | |
| 837 | + MPEG4Level1 = 0x04, | |
| 838 | + MPEG4Level2 = 0x08, | |
| 839 | + MPEG4Level3 = 0x10, | |
| 840 | + MPEG4Level3b = 0x18, | |
| 841 | + MPEG4Level4 = 0x20, | |
| 842 | + MPEG4Level4a = 0x40, | |
| 843 | + MPEG4Level5 = 0x80, | |
| 844 | + MPEG4Level6 = 0x100, | |
| 845 | +}; | |
| 846 | + | |
| 847 | +static const AVOption mpeg4_options[] = { | |
| 848 | + COMMON_OPTION | |
| 849 | + { "level", "Specify tier and level", | |
| 850 | + OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE, "level" }, | |
| 851 | + { "0", "Level 0", | |
| 852 | + 0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level0 }, 0, 0, VE, "level" }, | |
| 853 | + { "0b", "Level 0b", | |
| 854 | + 0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level0b }, 0, 0, VE, "level" }, | |
| 855 | + { "1", "Level 1", | |
| 856 | + 0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level1 }, 0, 0, VE, "level" }, | |
| 857 | + { "2", "Level 2", | |
| 858 | + 0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level2 }, 0, 0, VE, "level" }, | |
| 859 | + { "3", "Level 3", | |
| 860 | + 0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level3 }, 0, 0, VE, "level" }, | |
| 861 | + { "3b", "Level 3b", | |
| 862 | + 0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level3b }, 0, 0, VE, "level" }, | |
| 863 | + { "4", "Level 4", | |
| 864 | + 0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level4 }, 0, 0, VE, "level" }, | |
| 865 | + { "4a", "Level 4a", | |
| 866 | + 0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level4a }, 0, 0, VE, "level" }, | |
| 867 | + { "5", "Level 5", | |
| 868 | + 0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level5 }, 0, 0, VE, "level" }, | |
| 869 | + { "6", "Level 6", | |
| 870 | + 0, AV_OPT_TYPE_CONST, { .i64 = MPEG4Level6 }, 0, 0, VE, "level" }, | |
| 871 | + { NULL, } | |
| 872 | +}; | |
| 873 | + | |
| 874 | +DECLARE_MEDIACODEC_ENCODER(mpeg4, "MPEG-4", AV_CODEC_ID_MPEG4) | |
| 875 | + | |
| 876 | +#endif // CONFIG_MPEG4_MEDIACODEC_ENCODER | |
| @@ -29,7 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | |
| 30 | 30 | #include "version_major.h" |
| 31 | 31 | |
| 32 | −#define LIBAVCODEC_VERSION_MINOR 8 | |
| 32 | +#define LIBAVCODEC_VERSION_MINOR 9 | |
| 33 | 33 | #define LIBAVCODEC_VERSION_MICRO 100 |
| 34 | 34 | |
| 35 | 35 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |