Commit d52208e8 authored by Julian Scheel's avatar Julian Scheel Committed by Anton Khirnov

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: 's avatarJulian Scheel <julian@jusst.de>
Signed-off-by: 's avatarwm4 <nfxjfg@googlemail.com>
Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
parent 2689bb11
...@@ -55,6 +55,7 @@ version <next>: ...@@ -55,6 +55,7 @@ version <next>:
- libnpp/CUDA-accelerated format conversion and scaling - libnpp/CUDA-accelerated format conversion and scaling
- VAAPI-accelerate H.264/HEVC/MJPEG encoding - VAAPI-accelerate H.264/HEVC/MJPEG encoding
- Generic OpenMAX IL encoder with support for Raspberry Pi - Generic OpenMAX IL encoder with support for Raspberry Pi
- MMAL-accelerated MPEG-2 decoding
version 11: version 11:
......
...@@ -2133,6 +2133,9 @@ mpeg2_d3d11va_hwaccel_deps="d3d11va" ...@@ -2133,6 +2133,9 @@ mpeg2_d3d11va_hwaccel_deps="d3d11va"
mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder" mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
mpeg2_dxva2_hwaccel_deps="dxva2" mpeg2_dxva2_hwaccel_deps="dxva2"
mpeg2_dxva2_hwaccel_select="mpeg2video_decoder" mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
mpeg2_mmal_decoder_deps="mmal"
mpeg2_mmal_hwaccel_deps="mmal"
mpeg2_mmal_decoder_select="mpeg2video_decoder"
mpeg2_qsv_hwaccel_deps="libmfx" mpeg2_qsv_hwaccel_deps="libmfx"
mpeg2_vaapi_hwaccel_deps="vaapi" mpeg2_vaapi_hwaccel_deps="vaapi"
mpeg2_vaapi_hwaccel_select="mpeg2video_decoder" mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
......
...@@ -314,6 +314,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o ...@@ -314,6 +314,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
OBJS-$(CONFIG_MPEG2_MMAL_DECODER) += mmaldec.o
OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o
OBJS-$(CONFIG_MSA1_DECODER) += mss3.o OBJS-$(CONFIG_MSA1_DECODER) += mss3.o
OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o OBJS-$(CONFIG_MSMPEG4V1_DECODER) += msmpeg4dec.o msmpeg4.o msmpeg4data.o
......
...@@ -83,6 +83,7 @@ void avcodec_register_all(void) ...@@ -83,6 +83,7 @@ void avcodec_register_all(void)
REGISTER_HWACCEL(MPEG1_VDPAU, mpeg1_vdpau); REGISTER_HWACCEL(MPEG1_VDPAU, mpeg1_vdpau);
REGISTER_HWACCEL(MPEG2_D3D11VA, mpeg2_d3d11va); REGISTER_HWACCEL(MPEG2_D3D11VA, mpeg2_d3d11va);
REGISTER_HWACCEL(MPEG2_DXVA2, mpeg2_dxva2); REGISTER_HWACCEL(MPEG2_DXVA2, mpeg2_dxva2);
REGISTER_HWACCEL(MPEG2_MMAL, mpeg2_mmal);
REGISTER_HWACCEL(MPEG2_QSV, mpeg2_qsv); REGISTER_HWACCEL(MPEG2_QSV, mpeg2_qsv);
REGISTER_HWACCEL(MPEG2_VAAPI, mpeg2_vaapi); REGISTER_HWACCEL(MPEG2_VAAPI, mpeg2_vaapi);
REGISTER_HWACCEL(MPEG2_VDPAU, mpeg2_vdpau); REGISTER_HWACCEL(MPEG2_VDPAU, mpeg2_vdpau);
...@@ -200,6 +201,7 @@ void avcodec_register_all(void) ...@@ -200,6 +201,7 @@ void avcodec_register_all(void)
#endif /* FF_API_XVMC */ #endif /* FF_API_XVMC */
REGISTER_ENCDEC (MPEG1VIDEO, mpeg1video); REGISTER_ENCDEC (MPEG1VIDEO, mpeg1video);
REGISTER_ENCDEC (MPEG2VIDEO, mpeg2video); REGISTER_ENCDEC (MPEG2VIDEO, mpeg2video);
REGISTER_DECODER(MPEG2_MMAL, mpeg2_mmal);
REGISTER_DECODER(MPEG2_QSV, mpeg2_qsv); REGISTER_DECODER(MPEG2_QSV, mpeg2_qsv);
REGISTER_ENCDEC (MPEG4, mpeg4); REGISTER_ENCDEC (MPEG4, mpeg4);
REGISTER_DECODER(MSA1, msa1); REGISTER_DECODER(MSA1, msa1);
......
...@@ -351,7 +351,17 @@ static av_cold int ffmmal_init_decoder(AVCodecContext *avctx) ...@@ -351,7 +351,17 @@ static av_cold int ffmmal_init_decoder(AVCodecContext *avctx)
format_in = decoder->input[0]->format; format_in = decoder->input[0]->format;
format_in->type = MMAL_ES_TYPE_VIDEO; format_in->type = MMAL_ES_TYPE_VIDEO;
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; 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.width = FFALIGN(avctx->width, 32);
format_in->es->video.height = FFALIGN(avctx->height, 16); format_in->es->video.height = FFALIGN(avctx->height, 16);
format_in->es->video.crop.width = avctx->width; format_in->es->video.crop.width = avctx->width;
...@@ -760,31 +770,44 @@ AVHWAccel ff_h264_mmal_hwaccel = { ...@@ -760,31 +770,44 @@ AVHWAccel ff_h264_mmal_hwaccel = {
.pix_fmt = AV_PIX_FMT_MMAL, .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[]={ static const AVOption options[]={
{"extra_buffers", "extra buffers", offsetof(MMALDecodeContext, extra_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0}, {"extra_buffers", "extra buffers", offsetof(MMALDecodeContext, extra_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0},
{NULL} {NULL}
}; };
static const AVClass ffmmaldec_class = { #define FFMMAL_DEC_CLASS(NAME) \
.class_name = "mmaldec", static const AVClass ffmmal_##NAME##_dec_class = { \
.option = options, .class_name = "mmal_" #NAME "_dec", \
.version = LIBAVUTIL_VERSION_INT, .option = options, \
}; .version = LIBAVUTIL_VERSION_INT, \
};
AVCodec ff_h264_mmal_decoder = {
.name = "h264_mmal", #define FFMMAL_DEC(NAME, ID) \
.long_name = NULL_IF_CONFIG_SMALL("h264 (mmal)"), FFMMAL_DEC_CLASS(NAME) \
.type = AVMEDIA_TYPE_VIDEO, AVCodec ff_##NAME##_mmal_decoder = { \
.id = AV_CODEC_ID_H264, .name = #NAME "_mmal", \
.priv_data_size = sizeof(MMALDecodeContext), .long_name = NULL_IF_CONFIG_SMALL(#NAME " (mmal)"), \
.init = ffmmal_init_decoder, .type = AVMEDIA_TYPE_VIDEO, \
.close = ffmmal_close_decoder, .id = ID, \
.decode = ffmmal_decode, .priv_data_size = sizeof(MMALDecodeContext), \
.flush = ffmmal_flush, .init = ffmmal_init_decoder, \
.priv_class = &ffmmaldec_class, .close = ffmmal_close_decoder, \
.capabilities = AV_CODEC_CAP_DELAY, .decode = ffmmal_decode, \
.caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, .flush = ffmmal_flush, \
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MMAL, .priv_class = &ffmmal_##NAME##_dec_class, \
AV_PIX_FMT_YUV420P, .capabilities = AV_CODEC_CAP_DELAY, \
AV_PIX_FMT_NONE}, .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)
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
#include "libavutil/version.h" #include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 57 #define LIBAVCODEC_VERSION_MAJOR 57
#define LIBAVCODEC_VERSION_MINOR 18 #define LIBAVCODEC_VERSION_MINOR 19
#define LIBAVCODEC_VERSION_MICRO 2 #define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \ LIBAVCODEC_VERSION_MINOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment