[FFmpeg-devel] [PATCHv3 4/4] libavcodec: v4l2: add support for v4l2 mem2mem codecs
Jorge Ramirez
jorge.ramirez-ortiz at linaro.org
Thu Aug 3 17:51:13 EEST 2017
On 08/03/2017 01:53 AM, Mark Thompson wrote:
> On 02/08/17 08:32, Jorge Ramirez-Ortiz wrote:
>> ...
>> diff --git a/compat/v4l2/v4l2-common.h b/compat/v4l2/v4l2-common.h
>> diff --git a/compat/v4l2/videodev2.h b/compat/v4l2/videodev2.h
> These are discussed in other threads. I don't really have any comment either way.
ok. will be ammended in v4.
>
>> diff --git a/configure b/configure
>> index ed94de0..650c8fb 100755
>> --- a/configure
>> +++ b/configure
>> @@ -10,7 +10,6 @@
>> # Prevent locale nonsense from breaking basic text processing.
>> LC_ALL=C
>> export LC_ALL
>> -
> Spurious change?
ack
>
>> # make sure we are running under a compatible shell
>> # try to make this part work with most shells
>>
>> @@ -149,6 +148,7 @@ Component options:
>> --disable-pixelutils disable pixel utils in libavutil
>>
>> Individual component options:
>> + --disable-v4l2_m2m disable V4L2 mem2mem code [autodetect]
> s/_/-/ here.
ack
>
>> --disable-everything disable all components listed below
>> --disable-encoder=NAME disable encoder NAME
>> --enable-encoder=NAME enable encoder NAME
>> @@ -1432,6 +1432,7 @@ AVCODEC_COMPONENTS="
>>
>> AVDEVICE_COMPONENTS="
>> indevs
>> + v4l2_m2m
>> outdevs
>> "
>> AVFILTER_COMPONENTS="
>> @@ -2269,11 +2270,12 @@ map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
>>
>> loongson2_deps="mips"
>> loongson3_deps="mips"
>> -v4l2_deps_any="linux_videodev2_h sys_videoio_h"
>> +v4l2_m2m_select="v4l2"
>> mipsfpu_deps="mips"
>> mipsdsp_deps="mips"
>> mipsdspr2_deps="mips"
>> mips32r2_deps="mips"
>> +vc1_v4l2m2m_decoder_deps="v4l2_m2m"
>> mips32r5_deps="mips"
>> mips32r6_deps="mips"
>> mips64r2_deps="mips"
>> @@ -2284,6 +2286,9 @@ mmi_deps="mips"
>> altivec_deps="ppc"
>> dcbzl_deps="ppc"
>> ldbrx_deps="ppc"
>> +vp8_v4l2m2m_decoder_deps="v4l2_m2m"
>> +vp8_v4l2m2m_encoder_deps="v4l2_m2m"
>> +vp9_v4l2m2m_decoder_deps="v4l2_m2m"
> These seem to be placed randomly in the file. There is a hardware codec section at around line 2800, put all of these declarations there.
thanks for the guideline. will do.
>
>> ppc4xx_deps="ppc"
>> vsx_deps="altivec"
>> power8_deps="vsx"
>> @@ -2437,15 +2442,22 @@ h261_decoder_select="mpegvideo"
>> h261_encoder_select="aandcttables mpegvideoenc"
>> h263_decoder_select="h263_parser h263dsp mpegvideo qpeldsp"
>> h263_encoder_select="aandcttables h263dsp mpegvideoenc"
>> +h263_v4l2m2m_decoder_deps="v4l2_m2m"
>> +h263_v4l2m2m_encoder_deps="v4l2_m2m"
>> h263i_decoder_select="h263_decoder"
>> h263p_decoder_select="h263_decoder"
>> h263p_encoder_select="h263_encoder"
>> h264_decoder_select="cabac golomb h264chroma h264dsp h264parse h264pred h264qpel videodsp"
>> h264_decoder_suggest="error_resilience"
>> +h264_v4l2m2m_decoder_deps="v4l2_m2m"
>> +h264_v4l2m2m_encoder_deps="v4l2_m2m"
>> hap_decoder_select="snappy texturedsp"
>> hap_encoder_deps="libsnappy"
>> hap_encoder_select="texturedspenc"
>> hevc_decoder_select="bswapdsp cabac golomb hevcparse videodsp"
>> +hevc_encoder_select="hevc_v4l2m2m"
>> +hevc_v4l2m2m_decoder_deps="v4l2_m2m"
>> +hevc_v4l2m2m_encoder_deps="v4l2_m2m"
>> huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp"
>> huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llvidencdsp"
>> iac_decoder_select="imc_decoder"
>> @@ -2482,6 +2494,7 @@ mpc7_decoder_select="bswapdsp mpegaudiodsp"
>> mpc8_decoder_select="mpegaudiodsp"
>> mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
>> mpeg_xvmc_decoder_select="mpeg2video_decoder"
>> +mpeg1_v4l2m2m_decoder_deps="v4l2_m2m"
>> mpegvideo_decoder_select="mpegvideo"
>> mpeg1video_decoder_select="mpegvideo"
>> mpeg1video_encoder_select="aandcttables mpegvideoenc h263dsp"
>> @@ -2489,6 +2502,8 @@ mpeg2video_decoder_select="mpegvideo"
>> mpeg2video_encoder_select="aandcttables mpegvideoenc h263dsp"
>> mpeg4_decoder_select="h263_decoder mpeg4video_parser"
>> mpeg4_encoder_select="h263_encoder"
>> +mpeg4_v4l2m2m_decoder_deps="v4l2_m2m"
>> +mpeg4_v4l2m2m_encoder_deps="v4l2_m2m"
>> msa1_decoder_select="mss34dsp"
>> mscc_decoder_select="zlib"
>> msmpeg4v1_decoder_select="h263_decoder"
>> @@ -3042,7 +3057,6 @@ qtkit_indev_select="qtkit"
>> sdl2_outdev_deps="sdl2"
>> sndio_indev_deps="sndio"
>> sndio_outdev_deps="sndio"
>> -v4l_indev_deps="linux_videodev_h"
>> v4l2_indev_select="v4l2"
>> v4l2_outdev_select="v4l2"
>> vfwcap_indev_deps="vfw32 vfwcap_defines"
>> @@ -3592,7 +3606,7 @@ done
>> enable_weak audiotoolbox
>>
>> # Enable hwaccels by default.
>> -enable_weak d3d11va dxva2 vaapi vda vdpau videotoolbox_hwaccel xvmc
>> +enable_weak d3d11va dxva2 vaapi v4l2_m2m vda vdpau videotoolbox_hwaccel xvmc
>> enable_weak xlib
>>
>> enable_weak cuda cuvid nvenc vda_framework videotoolbox videotoolbox_encoder
>> @@ -6058,12 +6072,10 @@ pod2man --help > /dev/null 2>&1 && enable pod2man || disable pod2man
>> rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || disable rsync_contimeout
>>
>> check_header linux/fb.h
>> -check_header linux/videodev.h
>> -check_header linux/videodev2.h
>> -check_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_safe struct_v4l2_frmivalenum_discrete
>>
>> check_header sys/videoio.h
>> check_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_safe struct_v4l2_frmivalenum_discrete
>> +add_cflags -I$source_path/compat/v4l2
> Unconditionally? Sounds useful on Windows.
yes forgot to restrict it. will be removed anyway on v4.
>
>>
>> check_lib user32 "windows.h winuser.h" GetShellWindow -luser32
>> check_lib vfw32 "windows.h vfw.h" capCreateCaptureWindow -lvfw32
>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
>> index 364aec9..f45050e 100644
>> --- a/libavcodec/Makefile
>> +++ b/libavcodec/Makefile
>> @@ -101,7 +101,8 @@ OBJS-$(CONFIG_LZF) += lzf.o
>> OBJS-$(CONFIG_MDCT) += mdct_fixed.o mdct_float.o mdct_fixed_32.o
>> OBJS-$(CONFIG_ME_CMP) += me_cmp.o
>> OBJS-$(CONFIG_MEDIACODEC) += mediacodecdec_common.o mediacodec_surface.o mediacodec_wrapper.o mediacodec_sw_buffer.o
>> -OBJS-$(CONFIG_V4L2) += v4l2-common.o
>> +OBJS-$(CONFIG_V4L2) += v4l2_fmt.o v4l2_buffers.o
>> +OBJS-$(CONFIG_V4L2_M2M) += v4l2_m2m.o
> Random placing? These should be in alphabetical order.
ack
>
>> OBJS-$(CONFIG_MPEG_ER) += mpeg_er.o
>> OBJS-$(CONFIG_MPEGAUDIO) += mpegaudio.o
>> OBJS-$(CONFIG_MPEGAUDIODSP) += mpegaudiodsp.o \
>> @@ -320,6 +321,8 @@ OBJS-$(CONFIG_H261_ENCODER) += h261enc.o h261data.o h261.o
>> OBJS-$(CONFIG_H263_DECODER) += h263dec.o h263.o ituh263dec.o \
>> mpeg4video.o mpeg4videodec.o flvdec.o\
>> intelh263dec.o h263data.o
>> +OBJS-$(CONFIG_H263_V4L2M2M_DECODER) += v4l2_m2m_dec.o
>> +OBJS-$(CONFIG_H263_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
>> OBJS-$(CONFIG_H263_ENCODER) += mpeg4videoenc.o mpeg4video.o \
>> h263.o ituh263enc.o flvenc.o h263data.o
>> OBJS-$(CONFIG_H264_DECODER) += h264dec.o h264_cabac.o h264_cavlc.o \
>> @@ -327,6 +330,8 @@ OBJS-$(CONFIG_H264_DECODER) += h264dec.o h264_cabac.o h264_cavlc.o \
>> h264_mb.o h264_picture.o \
>> h264_refs.o h264_sei.o \
>> h264_slice.o h264data.o
>> +OBJS-$(CONFIG_H264_V4L2M2M_DECODER) += v4l2_m2m_dec.o
>> +OBJS-$(CONFIG_H264_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
>> OBJS-$(CONFIG_H264_CUVID_DECODER) += cuvid.o
>> OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec.o
>> OBJS-$(CONFIG_H264_MMAL_DECODER) += mmaldec.o
>> @@ -346,6 +351,8 @@ OBJS-$(CONFIG_HEVC_DECODER) += hevcdec.o hevc_mvs.o \
>> hevcdsp.o hevc_filter.o hevc_data.o
>> OBJS-$(CONFIG_HEVC_CUVID_DECODER) += cuvid.o
>> OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o
>> +OBJS-$(CONFIG_HEVC_V4L2M2M_DECODER) += v4l2_m2m_dec.o
>> +OBJS-$(CONFIG_HEVC_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
>> OBJS-$(CONFIG_HEVC_NVENC_ENCODER) += nvenc_hevc.o
>> OBJS-$(CONFIG_NVENC_HEVC_ENCODER) += nvenc_hevc.o
>> OBJS-$(CONFIG_HEVC_QSV_DECODER) += qsvdec_h2645.o
>> @@ -419,11 +426,13 @@ OBJS-$(CONFIG_MP3ON4FLOAT_DECODER) += mpegaudiodec_float.o mpeg4audio.o
>> OBJS-$(CONFIG_MPC7_DECODER) += mpc7.o mpc.o
>> OBJS-$(CONFIG_MPC8_DECODER) += mpc8.o mpc.o
>> OBJS-$(CONFIG_MPEGVIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
>> +OBJS-$(CONFIG_MPEG1_V4L2M2M_DECODER) += v4l2_m2m_dec.o
>> OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
>> OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
>> OBJS-$(CONFIG_MPEG2_MMAL_DECODER) += mmaldec.o
>> OBJS-$(CONFIG_MPEG2_QSV_DECODER) += qsvdec_other.o
>> OBJS-$(CONFIG_MPEG2_QSV_ENCODER) += qsvenc_mpeg2.o
>> +OBJS-$(CONFIG_MPEG2_V4L2M2M_DECODER) += v4l2_m2m_dec.o
>> OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
>> OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
>> OBJS-$(CONFIG_MPEG2_MEDIACODEC_DECODER) += mediacodecdec.o
>> @@ -431,6 +440,8 @@ OBJS-$(CONFIG_MPEG2_VAAPI_ENCODER) += vaapi_encode_mpeg2.o
>> OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o
>> OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o
>> OBJS-$(CONFIG_MPEG4_OMX_ENCODER) += omx.o
>> +OBJS-$(CONFIG_MPEG4_V4L2M2M_DECODER) += v4l2_m2m_dec.o
>> +OBJS-$(CONFIG_MPEG4_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
>> OBJS-$(CONFIG_MPL2_DECODER) += mpl2dec.o ass.o
>> OBJS-$(CONFIG_MSA1_DECODER) += mss3.o
>> OBJS-$(CONFIG_MSCC_DECODER) += mscc.o
>> @@ -503,6 +514,7 @@ OBJS-$(CONFIG_RALF_DECODER) += ralf.o
>> OBJS-$(CONFIG_RAWVIDEO_DECODER) += rawdec.o
>> OBJS-$(CONFIG_RAWVIDEO_ENCODER) += rawenc.o
>> OBJS-$(CONFIG_REALTEXT_DECODER) += realtextdec.o ass.o
>> +OBJS-$(CONFIG_VC1_V4L2M2M_DECODER) += v4l2_m2m_dec.o
>> OBJS-$(CONFIG_RL2_DECODER) += rl2.o
>> OBJS-$(CONFIG_ROQ_DECODER) += roqvideodec.o roqvideo.o
>> OBJS-$(CONFIG_ROQ_ENCODER) += roqvideoenc.o roqvideo.o elbg.o
>> @@ -518,6 +530,8 @@ OBJS-$(CONFIG_RV30_DECODER) += rv30.o rv34.o rv30dsp.o
>> OBJS-$(CONFIG_RV40_DECODER) += rv40.o rv34.o rv40dsp.o
>> OBJS-$(CONFIG_SAMI_DECODER) += samidec.o ass.o htmlsubtitles.o
>> OBJS-$(CONFIG_S302M_DECODER) += s302m.o
>> +OBJS-$(CONFIG_VP8_V4L2M2M_DECODER) += v4l2_m2m_dec.o
>> +OBJS-$(CONFIG_VP8_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
> As should all of the rest of these.
ah, I see..
>
>> OBJS-$(CONFIG_S302M_ENCODER) += s302menc.o
>> OBJS-$(CONFIG_SANM_DECODER) += sanm.o
>> OBJS-$(CONFIG_SCPR_DECODER) += scpr.o
>> @@ -628,6 +642,8 @@ 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) += cuvid.o
>> OBJS-$(CONFIG_VP9_MEDIACODEC_DECODER) += mediacodecdec.o
>> +OBJS-$(CONFIG_VP9_V4L2M2M_DECODER) += v4l2_m2m_dec.o
>> +OBJS-$(CONFIG_VP9_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
>> OBJS-$(CONFIG_VP9_VAAPI_ENCODER) += vaapi_encode_vp9.o
>> OBJS-$(CONFIG_VPLAYER_DECODER) += textdec.o ass.o
>> OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
>> index 4712592..d154ac9 100644
>> --- a/libavcodec/allcodecs.c
>> +++ b/libavcodec/allcodecs.c
>> @@ -207,8 +207,10 @@ static void register_all(void)
>> REGISTER_ENCDEC (H263, h263);
>> REGISTER_DECODER(H263I, h263i);
>> REGISTER_ENCDEC (H263P, h263p);
>> + REGISTER_ENCDEC (H263_V4L2M2M, h263_v4l2m2m);
>> REGISTER_DECODER(H264, h264);
>> REGISTER_DECODER(H264_CRYSTALHD, h264_crystalhd);
>> + REGISTER_ENCDEC (H264_V4L2M2M, h264_v4l2m2m);
>> REGISTER_DECODER(H264_MEDIACODEC, h264_mediacodec);
>> REGISTER_DECODER(H264_MMAL, h264_mmal);
>> REGISTER_DECODER(H264_QSV, h264_qsv);
>> @@ -219,6 +221,7 @@ static void register_all(void)
>> REGISTER_ENCDEC (HAP, hap);
>> REGISTER_DECODER(HEVC, hevc);
>> REGISTER_DECODER(HEVC_QSV, hevc_qsv);
>> + REGISTER_ENCDEC(HEVC_V4L2M2M, hevc_v4l2m2m);
>> REGISTER_DECODER(HNM4_VIDEO, hnm4_video);
>> REGISTER_DECODER(HQ_HQA, hq_hqa);
>> REGISTER_DECODER(HQX, hqx);
>> @@ -253,6 +256,7 @@ static void register_all(void)
>> REGISTER_ENCDEC (MPEG2VIDEO, mpeg2video);
>> REGISTER_ENCDEC (MPEG4, mpeg4);
>> REGISTER_DECODER(MPEG4_CRYSTALHD, mpeg4_crystalhd);
>> + REGISTER_ENCDEC (MPEG4_V4L2M2M, mpeg4_v4l2m2m);
>> REGISTER_DECODER(MPEG4_MMAL, mpeg4_mmal);
>> #if FF_API_VDPAU
>> REGISTER_DECODER(MPEG4_VDPAU, mpeg4_vdpau);
>> @@ -262,8 +266,10 @@ static void register_all(void)
>> REGISTER_DECODER(MPEG_VDPAU, mpeg_vdpau);
>> REGISTER_DECODER(MPEG1_VDPAU, mpeg1_vdpau);
>> #endif
>> + REGISTER_DECODER(MPEG1_V4L2M2M, mpeg1_v4l2m2m);
>> REGISTER_DECODER(MPEG2_MMAL, mpeg2_mmal);
>> REGISTER_DECODER(MPEG2_CRYSTALHD, mpeg2_crystalhd);
>> + REGISTER_DECODER(MPEG2_V4L2M2M, mpeg2_v4l2m2m);
>> REGISTER_DECODER(MPEG2_QSV, mpeg2_qsv);
>> REGISTER_DECODER(MPEG2_MEDIACODEC, mpeg2_mediacodec);
>> REGISTER_DECODER(MSA1, msa1);
>> @@ -361,6 +367,7 @@ static void register_all(void)
>> REGISTER_DECODER(VC1IMAGE, vc1image);
>> REGISTER_DECODER(VC1_MMAL, vc1_mmal);
>> REGISTER_DECODER(VC1_QSV, vc1_qsv);
>> + REGISTER_DECODER(VC1_V4L2M2M, vc1_v4l2m2m);
>> REGISTER_ENCODER(VC2, vc2);
>> REGISTER_DECODER(VCR1, vcr1);
>> REGISTER_DECODER(VMDVIDEO, vmdvideo);
>> @@ -372,7 +379,9 @@ static void register_all(void)
>> REGISTER_DECODER(VP6F, vp6f);
>> REGISTER_DECODER(VP7, vp7);
>> REGISTER_DECODER(VP8, vp8);
>> + REGISTER_ENCDEC (VP8_V4L2M2M, vp8_v4l2m2m);
>> REGISTER_DECODER(VP9, vp9);
>> + REGISTER_DECODER(VP9_V4L2M2M, vp9_v4l2m2m);
>> REGISTER_DECODER(VQA, vqa);
>> REGISTER_DECODER(BITPACKED, bitpacked);
>> REGISTER_DECODER(WEBP, webp);
> And these.
>
>> diff --git a/libavcodec/v4l2-common.c b/libavcodec/v4l2-common.c
>> deleted file mode 100644
>> diff --git a/libavcodec/v4l2-common.h b/libavcodec/v4l2-common.h
>> deleted file mode 100644
>> diff --git a/libavcodec/v4l2_fmt.c b/libavcodec/v4l2_fmt.c
>> new file mode 100644
>> diff --git a/libavcodec/v4l2_fmt.h b/libavcodec/v4l2_fmt.h
>> new file mode 100644
> I think it would have made more sense to move these files in a previous patch rather than here.
>
>
yes, that is changed on v4.
thanks!
More information about the ffmpeg-devel
mailing list