In this paper, based on the ffmpeg-2.2, add qsvavc_enc, qsvavc_dec, qsvmpeg2_dec, qsvvc1_dec Based on qsv (Intel Media SDK/quick sync video, enable and disable the command line parameter enable-qsv.
1. Add the corresponding code implementation in the libavcodec directory Refer to hevc. C and libx265.c. For example, qsvdec. C and qsvenc. C. The file name can start at will. Note the following red characters in the implementation. Ff_qsvavc_decoder/ff_qsvavc_encoder is a global variable. This global variable is referenced when the register_encdec macro is called in libavcodec/allcodecs. C to register the decoder. Therefore, the value must be consistent .. The name option affects the name of the FFMPEG command line parameter-vcodec.
Avcodec ff_qsvavc_decoder = {. name = "qsvavc ",. long_name = null_if_config_small ("H. 264/AVC decoder via intel Media SDK/quick sync video (qsv )"),. type = avmedia_type_video ,. id = av_codec_id_h264 ,. priv_data_size = sizeof (qsvcontext ),. init = qsv_decode_init_avc ,. close = qsv_decode_close ,. decode = qsv_decode_frame ,. flush = qsv_decode_flush ,. capabilities = codec_cap_dr1 | codec_cap_delay | codec_cap_truncated ,};
2. register the decoder in libavcodec/allcodecs. C.Round (qsvavc, qsvavc); register_decoder (qsvavc, qsvavc); register_decoder (qsvmpeg2, qsvmpeg2); register_decoder (qsvvc1, qsvvc1 );
Allcodecs. c defines three macros, register_encdec, register_decoder, and register_encoder, which are used to register the decoder. They are only encoder and only decoder. View the macro definition of register_decoder. First, reference the global ff_xxx_decoder variable and call the avcodec_register () function to add it to the decoder list.
# Define register_decoder (x, x) \ {\ extern avcodec FF _ # X # _ decoder; \ If (config _ # X # _ decoder) \ avcodec_register (& FF _ # x ###_ decoder );\}
3. Add the target file to libavcodec/makefile.Set. replace the c file name. oobjs-$ (config_qsv) + = qsvdec. oobjs-$ (config_qsv) + = qsvenc. O or objs-$ (config_qsvavc_decoder) + = qsvdec. oobjs-$ (config_qsvavc_encoder) + = qsvenc. o $ (config_xxx) in. /config. mak.
4. Modify the configure file so that the decoder can be disabled and enabled at./configure.This step is not found in some online articles.
Search for the show_help () function and Add./configure -- help to display the help, which is not required. -- Enable-qsv enable codecs via intel Media SDK
Add qsv to the external_library_list variable. Otherwise,./configure -- enable-qsv will prompt that this option is not available. In addition,./configure generates the # define config_qsv 1 of config. h and config_qsv = yes of config. Mak based on this.
Add dependencies to associate the configuration items qsvavc_decoder/qsvavc_encoder and -- enable-qsv. You can search for "libx264_encoder_deps" and add it later. Qsvavc_decoder_deps = "qsv" qsvavc_encoder_deps = "qsv" qsvmpeg2_decoder_deps = "qsv" qsvvc1_decoder_deps = "qsv"
Check for adding dependent libraries. You can search for "enabled libx264" and add it later. Enabled qsv & {check_lib mfxvideo. h mfxinit-lmfxhw64-LVA-DRM | die "error: Intel Media SDK not found ";}
5. macro definition and environment variable generation during configureConfig. h # define config_qsv 1 # define config_qsvavc_decoder 1 # define config_qsvmpeg2_decoder 1 # define config_qsvvc1_decoder 1 # define config_bintext_decoder 1
Config. makconfig_qsv = yesconfig_qsvavc_decoder = yesconfig_qsvmpeg2_decoder = yesconfig_qsvvc1_decoder = yesconfig_bintext_decoder = Yes
$ All_components-> $ decoder_list-> find_things () uses sed to extract the decoder from allcodecs. C and add it to the $ all_components list.
Configure-> check_deps () $ all_components the default value is yes-> do_check_deps (). Based on the dependency check of qsvavc_decoder_deps, disable does not conform to the dependency. For example, if the dependency of qsvavc_decoder is set to qsvavc_decoder_deps = "qsv", the -- enable-qsv parameter is not added during Configure. If the value of qsvavc_decoder is set to yes, do_check_deps, change the value of qsvavc_decoder to No.
Configure-> print_config () reads the values of $ all_components and generates macro definitions or environment variables in config. h or config. Mak. For example, if the value of the qsvavc_decoder item is no, the config_qsvavc_decoder 0 and config_qsvavc_decoder = yes in config. Mak are generated. Map 'eval echo "$ V \$ {$ V:-No}" '"[email protected]"
If qsvavc_decoder_deps = "qsv" is not correctly added, # define config_qsvavc_decoder 1 and config_qsvavc_decoder = yes are generated, which leads to incorrect compilation of the corresponding modules, however, if the search path of the associated library and header file is not added, compilation errors may occur.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.