diff options
author | Julian Scheel <julian@jusst.de> | 2016-04-14 13:21:19 +0300 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2016-04-30 09:11:13 +0300 |
commit | d52208e8d549d4c84a2a348aa3790b1a177e779a (patch) | |
tree | a57127c71d20020b388cd33573d6e7f3681608c4 /libavcodec | |
parent | 2689bb115ca64921789092148deaf213a0d94d2e (diff) |
mmaldec: Add mpeg2 decoding support
Register mmaldec as mpeg2 decoder. Supporting mpeg2 in mmaldec is just a
matter of setting the correct MMAL_ENCODING on the input port. To ease the
addition of further supported mmal codecs a macro is introduced to generate
the decoder and decoder class structs.
Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/Makefile | 1 | ||||
-rw-r--r-- | libavcodec/allcodecs.c | 2 | ||||
-rw-r--r-- | libavcodec/mmaldec.c | 71 | ||||
-rw-r--r-- | libavcodec/version.h | 4 |
4 files changed, 52 insertions, 26 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index ac1e2c4892..227538c05a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -314,6 +314,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o +OBJS-$(CONFIG_MPEG2_MMAL_DECODER) += mmaldec.o OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o OBJS-$(CONFIG_MSA1_DECODER) += mss3.o OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 9f9f0b3b31..854a05259b 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -83,6 +83,7 @@ void avcodec_register_all(void) REGISTER_HWACCEL(MPEG1_VDPAU, mpeg1_vdpau); REGISTER_HWACCEL(MPEG2_D3D11VA, mpeg2_d3d11va); REGISTER_HWACCEL(MPEG2_DXVA2, mpeg2_dxva2); + REGISTER_HWACCEL(MPEG2_MMAL, mpeg2_mmal); REGISTER_HWACCEL(MPEG2_QSV, mpeg2_qsv); REGISTER_HWACCEL(MPEG2_VAAPI, mpeg2_vaapi); REGISTER_HWACCEL(MPEG2_VDPAU, mpeg2_vdpau); @@ -200,6 +201,7 @@ void avcodec_register_all(void) #endif /* FF_API_XVMC */ REGISTER_ENCDEC (MPEG1VIDEO, mpeg1video); REGISTER_ENCDEC (MPEG2VIDEO, mpeg2video); + REGISTER_DECODER(MPEG2_MMAL, mpeg2_mmal); REGISTER_DECODER(MPEG2_QSV, mpeg2_qsv); REGISTER_ENCDEC (MPEG4, mpeg4); REGISTER_DECODER(MSA1, msa1); diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c index 4b980d214d..331a017910 100644 --- a/libavcodec/mmaldec.c +++ b/libavcodec/mmaldec.c @@ -351,7 +351,17 @@ static av_cold int ffmmal_init_decoder(AVCodecContext *avctx) format_in = decoder->input[0]->format; format_in->type = MMAL_ES_TYPE_VIDEO; - format_in->encoding = MMAL_ENCODING_H264; + switch (avctx->codec_id) { + case AV_CODEC_ID_MPEG2VIDEO: + format_in->encoding = MMAL_ENCODING_MP2V; + av_log(avctx, AV_LOG_DEBUG, "Use MMAL MP2V encoding\n"); + break; + case AV_CODEC_ID_H264: + default: + format_in->encoding = MMAL_ENCODING_H264; + av_log(avctx, AV_LOG_DEBUG, "Use MMAL H264 encoding\n"); + break; + } format_in->es->video.width = FFALIGN(avctx->width, 32); format_in->es->video.height = FFALIGN(avctx->height, 16); format_in->es->video.crop.width = avctx->width; @@ -760,31 +770,44 @@ AVHWAccel ff_h264_mmal_hwaccel = { .pix_fmt = AV_PIX_FMT_MMAL, }; +AVHWAccel ff_mpeg2_mmal_hwaccel = { + .name = "mpeg2_mmal", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_MPEG2VIDEO, + .pix_fmt = AV_PIX_FMT_MMAL, +}; + static const AVOption options[]={ {"extra_buffers", "extra buffers", offsetof(MMALDecodeContext, extra_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0}, {NULL} }; -static const AVClass ffmmaldec_class = { - .class_name = "mmaldec", - .option = options, - .version = LIBAVUTIL_VERSION_INT, -}; - -AVCodec ff_h264_mmal_decoder = { - .name = "h264_mmal", - .long_name = NULL_IF_CONFIG_SMALL("h264 (mmal)"), - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_H264, - .priv_data_size = sizeof(MMALDecodeContext), - .init = ffmmal_init_decoder, - .close = ffmmal_close_decoder, - .decode = ffmmal_decode, - .flush = ffmmal_flush, - .priv_class = &ffmmaldec_class, - .capabilities = AV_CODEC_CAP_DELAY, - .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, - .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MMAL, - AV_PIX_FMT_YUV420P, - AV_PIX_FMT_NONE}, -}; +#define FFMMAL_DEC_CLASS(NAME) \ + static const AVClass ffmmal_##NAME##_dec_class = { \ + .class_name = "mmal_" #NAME "_dec", \ + .option = options, \ + .version = LIBAVUTIL_VERSION_INT, \ + }; + +#define FFMMAL_DEC(NAME, ID) \ + FFMMAL_DEC_CLASS(NAME) \ + AVCodec ff_##NAME##_mmal_decoder = { \ + .name = #NAME "_mmal", \ + .long_name = NULL_IF_CONFIG_SMALL(#NAME " (mmal)"), \ + .type = AVMEDIA_TYPE_VIDEO, \ + .id = ID, \ + .priv_data_size = sizeof(MMALDecodeContext), \ + .init = ffmmal_init_decoder, \ + .close = ffmmal_close_decoder, \ + .decode = ffmmal_decode, \ + .flush = ffmmal_flush, \ + .priv_class = &ffmmal_##NAME##_dec_class, \ + .capabilities = AV_CODEC_CAP_DELAY, \ + .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, \ + .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MMAL, \ + AV_PIX_FMT_YUV420P, \ + AV_PIX_FMT_NONE}, \ + }; + +FFMMAL_DEC(h264, AV_CODEC_ID_H264) +FFMMAL_DEC(mpeg2, AV_CODEC_ID_MPEG2VIDEO) diff --git a/libavcodec/version.h b/libavcodec/version.h index 4c28cdc5dc..db3f33a6e6 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,8 +28,8 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 57 -#define LIBAVCODEC_VERSION_MINOR 18 -#define LIBAVCODEC_VERSION_MICRO 2 +#define LIBAVCODEC_VERSION_MINOR 19 +#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ |