CN105491387B - A H264 Hardware Encoding System Based on Intel, AMD and Nvidia - Google Patents
A H264 Hardware Encoding System Based on Intel, AMD and Nvidia Download PDFInfo
- Publication number
- CN105491387B CN105491387B CN201510887873.3A CN201510887873A CN105491387B CN 105491387 B CN105491387 B CN 105491387B CN 201510887873 A CN201510887873 A CN 201510887873A CN 105491387 B CN105491387 B CN 105491387B
- Authority
- CN
- China
- Prior art keywords
- encoder
- submodule
- interface
- hardware
- encoding
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
- 238000000034 method Methods 0.000 claims description 46
- 230000001133 acceleration Effects 0.000 claims description 6
- 238000010586 diagram Methods 0.000 description 6
- 230000006870 function Effects 0.000 description 6
- 230000001360 synchronised effect Effects 0.000 description 6
- 241000251468 Actinopterygii Species 0.000 description 2
- 230000003139 buffering effect Effects 0.000 description 2
- 238000007599 discharging Methods 0.000 description 2
- 238000005538 encapsulation Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000007613 environmental effect Effects 0.000 description 2
- 230000006872 improvement Effects 0.000 description 2
- 241000208340 Araliaceae Species 0.000 description 1
- 235000005035 Panax pseudoginseng ssp. pseudoginseng Nutrition 0.000 description 1
- 235000003140 Panax quinquefolius Nutrition 0.000 description 1
- 230000006835 compression Effects 0.000 description 1
- 238000007906 compression Methods 0.000 description 1
- 230000007423 decrease Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 235000008434 ginseng Nutrition 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000008520 organization Effects 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 239000011800 void material Substances 0.000 description 1
Landscapes
- Compression Or Coding Systems Of Tv Signals (AREA)
- Image Processing (AREA)
Abstract
The invention discloses a kind of H264 hardware encoding systems based on tri- platform of Intel, AMD and Nvidia, including universal coding module, Intel hardware coder, AMD hardware coder and Nvidia hardware coder, the wherein universal coding module, for creating universal coding interface, judge the hardware coder type that computer system is supported, any one of hardware coder type Selection and call Intel hardware coder, AMD hardware coder or Nvidia hardware coder supported according to computer system carries out H264 Video coding;Intel hardware coder, for carrying out H264 Video coding to the computer system for supporting Intel hardware encoding;AMD hardware coder, for carrying out H264 Video coding to the computer system for supporting AMD hardware encoding;Nvidia hardware coder, for carrying out H264 Video coding to the computer system for supporting Nvidia hardware encoding.The present invention can judge the hardware coder type that computer system is supported, to the offer H264 hardware encoding of a variety of different computer system unawares.
Description
Technical field
The invention belongs to graphics technology fields, flat based on Intel, AMD and Nvidia tri- more particularly, to one kind
The H264 hardware encoding system of platform.
Background technique
H.264 it is International Organization for standardization (ISO) and International Telecommunication Union (ITU) proposes jointly after MPEG4
New-generation digital video compression format.It H.264 is ITU-T with the H.26x serial video coding and decoding technology standard for name nominating
One of.It H.264 is the MPEG (Motion Picture Expert Group) of the VCEG (Video Coding Experts Group) and ISO/IEC of ITU-T
One digital video coding standard of joint video team (JVT:joint video team) exploitation.The standard earliest from
The exploitation for being referred to as project H.26L of ITU-T.H.26L this title is although less common, but is used always.
It H.264 is ITU-T with H.26x serial one of the standard for name nominating, AVC is the address of mono- side of ISO/IEC MPEG.
Most H264 coding uses the Software Coding of libx264 at present, in this way in the cpu performance ratio of computer
In the case where poor, central processing unit (Central Processing Unit, CPU) resource can be seriously consumed, computer is caused
The decline of service system performance;It even if some computers have used hardware encoding, but is only that the integrated of Intel platform is supported to show
Card or Nvidia platform, can not carry out unified support by this several large platform to Intel, AMD, Nvidia.
Summary of the invention
Aiming at the above defects or improvement requirements of the prior art, the present invention provides one kind based on Intel, AMD and
The H264 hardware encoding system of tri- platform of Nvidia, it is noninductive its object is to which the computer platform of different hardware platforms can be directed to
The corresponding hardware encoding scheme of the offer known, H264 hardware volume can not be carried out by thus solving part computer system under the prior art
The technical issues of code.
To achieve the above object, the present invention provides a kind of H264 hardware based on tri- platform of Intel, AMD and Nvidia
Coded system, including universal coding module, Intel hardware coder, AMD hardware coder and Nvidia hardware coder,
Wherein:
The universal coding module judges the hardware encoding that computer system is supported for creating universal coding interface
Device type, the hardware coder type Selection and call Intel hardware coder supported according to computer system, AMD hardware are compiled
Code any one of device or Nvidia hardware coder carry out H264 Video coding;
The Intel hardware coder, for carrying out H264 video volume to the computer system for supporting Intel hardware encoding
Code;
The AMD hardware coder, for carrying out H264 Video coding to the computer system for supporting AMD hardware encoding;
The Nvidia hardware coder, for carrying out H264 video to the computer system for supporting Nvidia hardware encoding
Coding.
In one embodiment of the present of invention, the universal coding module includes universaling coder interface sub-module and encoder
Implementation sub-module, in which:
The universaling coder interface sub-module includes for realizing the definition to encoder interfaces, the encoder interfaces
File Open interface, encoder type obtain interface, encoder creates interface, the throttling interface that writes, closing of a file interface,
In:
The File Open interface is used to open the file of coding result to be written, or establishes real-time messages transport protocol
(Time Messaging Protocol, RTMP) connection or real time streaming transport protocol (Real Time Streaming
Protocol, RTSP) connection, the input parameter of the File Open interface includes file path and reading and writing of files parameter;
The encoder type obtains interface for obtaining the encoder type that computer system is supported, so that the volume
The hardware coder for the encoder type creation respective type that code device creation interface is supported according to the computer system;
The encoder creation interface is used to obtain the encoder type that interface returns according to the encoder type and create
The encoder of respective type, input parameter are encoder type, are exported as respective type encoder, the encoder type is
Intel hardware coder perhaps AMD hardware coder or Nvidia hardware coder;
The throttling interface that writes is used to the byte stream after coding be written in the file of above-mentioned coding result to be written, or
Person is sent to RTMP server by the connection of RTMP agreement, or is sent to RTSP server by the connection of RTSP agreement;
The closing of a file interface is used to close the file being currently written into after end-of-encode, or closes established
The connection of RTMP agreement or the connection of RTSP agreement;
The encoder implementation sub-module is for determining encoder interfaces according to above-mentioned universaling coder interface sub-module
Justice creation encoder interfaces judge the hardware coder that computer system is supported using the encoder interfaces of creation, and selection is adjusted
H264 volume is carried out with any pair of video in Intel hardware coder, AMD hardware coder or Nvidia hardware coder
Code.
In one embodiment of the present of invention, the encoder interfaces further include written document head interface, and the written document head connects
Mouth is used for written document head, includes the H264 sequence sets parameter and PPSH264 image set ginseng of video encoder in the file header
Number, the H264 sequence sets parameter and PPSH264 image set parameter are used to use in decoder decoding.
In one embodiment of the present of invention, the encoder interfaces further include metadata information setting interface, the member number
It is believed that the metadata information that breath setting interface is used to be arranged in file.
In one embodiment of the present of invention, the encoder creation interface includes that encoder opens interface, encoder is closed
Interface and image addressable port, in which:
The encoder opens interface and is used to open encoder, and input parameter includes the view wide, to be encoded of video to be encoded
The height of frequency and the code rate of coding;
Described image addressable port is used for after above-mentioned encoder opening, and using encoder coded image, inputting parameter is
The image and scramble time stamp to be encoded;
The encoder down interface is used for after end-of-encode, closes the encoder of above-mentioned opening.
In one embodiment of the present of invention, the encoder type obtains interface and obtains the coding that computer system is supported
Device type specifically:
If returning to CT_QSV264, indicate that computer system supports Intel hardware encoding;
If returning to CT_AMD264, indicate that computer system supports AMD hardware encoding;
If returning to CT_NV264, indicate that computer system supports Nvidia hardware encoding;
If returning to CT_X264, indicate that computer system does not support any hardware encoding.
In one embodiment of the present of invention, described image addressable port specifically include byte streambuf setting up submodule,
Submodule, video frame Presentation Time Stamp setting submodule, screen frame decoding time stamp setting is arranged in byte stream buffer size
Module, key frame judging submodule and image addressable port discharge submodule, in which:
The byte streambuf setting up submodule is used for the decoded H264 byte streambuf of decoder for establishing,
Submodule is arranged in the byte stream buffer size, for being arranged for the decoded H264 byte stream buffering of decoder
Area's size;
Submodule is arranged in the video frame Presentation Time Stamp, shows the time for the decoded video frame of decoder for being arranged
Stamp;
The screen frame decoding time stamp setting submodule, for screen frame decoding time stamp to be arranged;
The key frame judging submodule, for judging whether present frame is key frame;
Described image addressable port discharges submodule, for discharging present image addressable port.
In one embodiment of the present of invention, the Intel hardware coder includes Intel hardware coder initialization submodule
Block, Intel hardware coder encoding submodule and Intel hardware coder close submodule, in which:
The Intel hardware coder initialization submodule specifically includes SDK for initializing Intel hardware coder
Initialization submodule, coding initialization submodule, video memory distribution sub module and Intel parameter acquisition submodule, in which:
The SDK initialization submodule is used to call the MediaSDK of MFXInit initialization Intel official;
The coding initialization submodule is for calling MFXVideoENCODE_Init to initialize encoder;
The video memory distribution sub module is specifically included for distributing the video memory surface for being used to receive image to be encoded;
MFXVideoENCODE_QueryIOSurf is called to obtain the video memory number of surfaces for needing to create;
IDirect3DDeviceManager9 interface is created, for providing video acceleration function;
The OpenDeviceHandle method of IDirect3DDeviceManager9 interface is called, equipment handle is obtained;
By the equipment handle of upper step, the side GetVideoService of IDirect3DDeviceManager9 interface is called
Method creates the IDirectXVideoDecoderService of IID_IDirectXVideoDecoderService (interface IID)
Interface;
The CreateSurface method that the IDirectXVideoDecoderService interface of creation is walked in calling has been come
At the creation on video acceleration surface;
The Intel parameter acquisition submodule be used for initialization encoder success after, obtain H264 sequence sets parameter and
H264 image set parameter;
The Intel hardware coder encoding submodule is used to carry out H264 coding to video, specifically includes image coding
Submodule and synchronous submodule, in which:
Described image encoding submodule, for calling MFXVideoENCODE_EncodeFrameAsync to NV12 format
Image encoded;
The synchronous submodule is for calling MFXVideoCORE_SyncOperation to carry out between CPU and GPU
It is synchronous, obtain the data flow that hardware encoding returns;
The Intel hardware coder closes submodule and is used to call MFXVideoENCODE_Close when stopping coding
Encoder is closed, carries out the release of resource, and call MFXClose to close Intel MediaSDK.
In one embodiment of the present of invention, the AMD hardware coder include AMD hardware coder initialization submodule,
AMD hardware coder encoding submodule and AMD hardware coder close submodule, in which:
The AMD hardware coder initialization submodule specifically includes DLL load for initializing AMD hardware coder
Submodule, interface creation submodule, parameter setting submodule and AMD parameter acquisition submodule, in which:
The DLL load submodule is for loading amf-core-windesktop32.dll and amf-component-
vce-windesktop32.dll;
The interface creation submodule is for calling AMFCreateContext to create AMFContext interface, and calling
AMFCreateComponent creates AMFComponent interface,
The parameter setting submodule is used to call the SetProperty of AMFComponent interface that relevant coding is arranged
Parameter, the coding parameter include resolution ratio, code rate and frame per second;And the Init method of AMFComponent interface is called to complete to compile
The initialization of code device;
The AMD parameter acquisition submodule is used to call the GetProperty method of AMFComponent interface, obtains
The H264 sequence sets parameter and PPSH264 image set parameter of AMF_VIDEO_ENCODER_EXTRADATA enumeration type;
The AMD hardware coder encoding submodule is used to carry out H264 coding to video, specifically includes video surface point
Submodule and AMD byte stream acquisition submodule are submitted in sub-module, video surface, in which:
The video surface distribution submodule is used to call the AllocSurface method of AMFContext interface to distribute and uses
To receive the video surface of image to be encoded;
The video surface submits submodule for calling the SubmitInput method of AMFComponent interface, will be upper
The video surface generated in step is submitted in encoder;
The AMD byte stream acquisition submodule is used to call the QueryOutput method of AMFComponent interface, obtains
Byte stream after encoder coding;
The AMD hardware coder closes submodule, for calling AMFComponent interface when stopping coding
Terminate method closes encoder, carries out the release of resource.
In one embodiment of the present of invention, the Nvidia hardware coder includes the initial beggar of Nvidia hardware coder
Module, Nvidia hardware coder encoding submodule and Nvidia hardware coder close submodule, in which:
The Nvidia hardware coder initialization submodule specifically includes volume for initializing Nvidia hardware coder
Code context initialization submodule, Nvidia parameter setting submodule, Nvidia parameter acquisition submodule and the creation of video memory surface
Submodule, in which:
For the coding environment initialization submodule for loading nvcuda.dll and nvEncodeAPI.dll, initialization must
The environment wanted;And the NvEncodeAPICreateInstance method of nvEncodeAPI module is called to create NV_ENCODE_
API_FUNCTION_LIST structure;And cuCtxCreate_v2 interface is called to create context environmental;
The Nvidia parameter setting submodule is for calling nvEncOpenEncodeSessionEx method creation coding
Device session, and call nvEncGetEncodePresetConfig to be configured coder parameters, and call
The initialization of nvEncInitializeEncoder completion encoder;
The Nvidia parameter acquisition submodule is NV_ for calling nvEncGetSequenceParams to obtain type
The H264 sequence sets parameter and PPSH264 image set parameter of ENC_SEQUENCE_PARAM_PAYLOAD_VER;
The video memory surface creation submodule is for calling nvEncCreateInputBuffer creation to be used to receive wait compile
The video memory surface of the image data of code, and call nvEncCreateBitstreamBuffer creation coding output storing data;
The Nvidia hardware coder encoding submodule is used to carry out H264 coding to video, specifically includes filling coding
Image submodule, encoding submodule and Nvidia byte stream acquisition submodule, in which:
The filling coded image submodule is for calling nvEncLockInputBuffer to lock above-mentioned video memory surface wound
The video memory surface of submodule creation is built, and fills coded image;And call nvEncUnlockInputBuffer to the video memory table
Face is unlocked;
The encoding submodule is for calling nvEncEncodePicture to be encoded;
What the Nvidia byte stream acquisition submodule was used to return after calling nvEncLockBitstream to obtain coding
Byte stream calls nvEncUnlockBitstream to discharge byte stream after doing corresponding processing;
The Nvidia hardware coder closes submodule, for calling when stopping coding
NvEncDestroyEncoder closes encoder, and cuCtxDestroy_v2 is called to discharge current environment context.
H264 hardware encoding system provided by the invention based on tri- platform of Intel, AMD and Nvidia, can judge to count
The hardware coder type that calculation machine system is supported, and according to the hardware coder type Selection and call Intel hardware encoding
Any pair of video for needing to play in the computer system in device, AMD hardware coder or Nvidia hardware coder
H264 coding is carried out, so as to the offer H264 hardware encoding to a variety of different computer system platform unawares.
Detailed description of the invention
Fig. 1 is the knot of the H264 hardware encoding system in the embodiment of the present invention based on tri- platform of Intel, AMD and Nvidia
Structure schematic diagram;
Fig. 2 is the structural schematic diagram of universaling coder interface sub-module in the embodiment of the present invention;
Fig. 3 is the structural schematic diagram of Intel hardware coder in the embodiment of the present invention;
Fig. 4 is the structural schematic diagram of AMD hardware coder in the embodiment of the present invention;
Fig. 5 is the structural schematic diagram of Nvidia hardware coder in the embodiment of the present invention;
Fig. 6 is that the uml class diagram of hardware encoding system in the embodiment of the present invention is intended to.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right
The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and
It is not used in the restriction present invention.As long as in addition, technical characteristic involved in the various embodiments of the present invention described below
Not constituting a conflict with each other can be combined with each other.
As shown in Figure 1, the present invention provides a kind of H264 hardware encoding systems based on tri- platform of Intel, AMD and Nvidia
System, including universal coding module, Intel hardware coder, AMD hardware coder and Nvidia hardware coder, in which:
The universal coding module judges the hardware encoding that computer system is supported for creating universal coding interface
Device type, the hardware coder type Selection and call Intel hardware coder supported according to computer system, AMD hardware are compiled
Code any one of device or Nvidia hardware coder carry out H264 Video coding;
Specifically, as shown in Fig. 2, the universal coding module includes that universaling coder interface sub-module and encoder execute
Submodule, in which:
The universaling coder interface sub-module includes for realizing the definition to encoder interfaces, the encoder interfaces
File Open interface, encoder type obtain interface, encoder creates interface, the throttling interface that writes, closing of a file interface,
In:
The File Open interface is used to open the file of coding result to be written, either establish RTMP agreement connection or
The connection of RTSP agreement, the input parameter of the File Open interface includes file path and reading and writing of files parameter;The file road
Diameter is the file path of local disk, or with RTMP: the RTMP agreement URL of //XXX beginning, or with RTSP: //XXX
The RTSP agreement URL of beginning, the reading and writing of files parameter are write-in;
The encoder type obtains interface for obtaining the encoder type that computer system is supported, so that the volume
The hardware coder for the encoder type creation respective type that code device creation interface is supported according to the computer system;
The encoder creation interface is used to obtain the encoder type that interface returns according to the encoder type and create
The encoder of respective type, input parameter are encoder type, are exported as respective type encoder, the encoder type is
Intel hardware coder perhaps AMD hardware coder or Nvidia hardware coder;Wherein the encoder creates interface
Interface, encoder down interface and image addressable port are opened including encoder, in which:
The encoder opens interface and is used to open encoder, and input parameter includes the view wide, to be encoded of video to be encoded
The height of frequency and the code rate of coding;
Described image addressable port is used for after above-mentioned encoder opening, and using encoder coded image, inputting parameter is
The image and scramble time stamp to be encoded;
Wherein described image addressable port specifically includes byte streambuf setting up submodule, byte stream buffer size is set
It sets submodule, video frame Presentation Time Stamp setting submodule, screen frame decoding time stamp setting submodule, key frame and judges submodule
Block and image addressable port discharge submodule, in which:
The byte streambuf setting up submodule is used for the decoded H264 byte streambuf of decoder for establishing,
Submodule is arranged in the byte stream buffer size, for being arranged for the decoded H264 byte stream buffering of decoder
Area's size;
Submodule is arranged in the video frame Presentation Time Stamp, shows the time for the decoded video frame of decoder for being arranged
Stamp;
The screen frame decoding time stamp setting submodule, for screen frame decoding time stamp to be arranged;
The key frame judging submodule, for judging whether present frame is key frame;
Described image addressable port discharges submodule, for discharging present image addressable port.
The encoder down interface is used for after end-of-encode, closes the encoder of above-mentioned opening.
The throttling interface that writes is used to the byte stream after coding be written in the file of above-mentioned coding result to be written, or
Person is sent to RTMP server by the connection of RTMP agreement, or is sent to RTSP server by the connection of RTSP agreement;
The closing of a file interface is used to close the file being currently written into after end-of-encode, or closes established
The connection of RTMP agreement or the connection of RTSP agreement;
Specifically, the encoder type obtains interface and obtains the encoder type that computer system is supported specifically:
If returning to CT_QSV264, indicate that computer system supports Intel hardware encoding;
If returning to CT_AMD264, indicate that computer system supports AMD hardware encoding;
If returning to CT_NV264, indicate that computer system supports Nvidia hardware encoding;
If returning to CT_X264, indicate that computer system does not support any hardware encoding.
Further, the encoder interfaces further include written document head interface, and the written document head interface is used for written document
Head includes the H264 sequence sets parameter and PPSH264 image set parameter of video encoder, the H264 sequence in the file header
Column collection parameter and PPSH264 image set parameter are used to use in decoder decoding.
Further, the encoder interfaces further include metadata information setting interface, and the metadata information setting connects
Metadata information of the mouth for being arranged in file.
The encoder implementation sub-module is for determining encoder interfaces according to above-mentioned universaling coder interface sub-module
Justice creation encoder interfaces judge the hardware coder that computer system is supported using the encoder interfaces of creation, and selection is adjusted
H264 volume is carried out with any pair of video in Intel hardware coder, AMD hardware coder or Nvidia hardware coder
Code, in which:
The Intel hardware coder, for carrying out H264 video volume to the computer system for supporting Intel hardware encoding
Code;
Specifically, as shown in figure 3, the Intel hardware coder include Intel hardware coder initialization submodule,
Intel hardware coder encoding submodule and Intel hardware coder close submodule, in which:
The Intel hardware coder initialization submodule specifically includes SDK for initializing Intel hardware coder
Initialization submodule, coding initialization submodule, video memory distribution sub module and Intel parameter acquisition submodule, in which:
The SDK initialization submodule is used to call the MediaSDK of MFXInit initialization Intel official;
The coding initialization submodule is for calling MFXVideoENCODE_Init to initialize encoder;
The video memory distribution sub module is specifically included for distributing the video memory surface for being used to receive image to be encoded;
MFXVideoENCODE_QueryIOSurf is called to obtain the video memory number of surfaces for needing to create;
IDirect3DDeviceManager9 interface is created, for providing video acceleration function;
The OpenDeviceHandle method of IDirect3DDeviceManager9 interface is called, equipment handle is obtained;
By the equipment handle of upper step, the side GetVideoService of IDirect3DDeviceManager9 interface is called
Method creates the IDirectXVideoDecoderService of IID_IDirectXVideoDecoderService (interface IID)
Interface;
The CreateSurface method that the IDirectXVideoDecoderService interface of creation is walked in calling has been come
At the creation on video acceleration surface;
The Intel parameter acquisition submodule be used for initialization encoder success after, obtain H264 sequence sets parameter and
H264 image set parameter;
The Intel hardware coder encoding submodule is used to carry out H264 coding to video, specifically includes image coding
Submodule and synchronous submodule, in which:
Described image encoding submodule, for calling MFXVideoENCODE_EncodeFrameAsync to NV12 format
Image encoded;
The synchronous submodule is for calling MFXVideoCORE_SyncOperation to carry out between CPU and GPU
It is synchronous, obtain the data flow that hardware encoding returns;
The Intel hardware coder closes submodule and is used to call MFXVideoENCODE_Close when stopping coding
Encoder is closed, carries out the release of resource, and call MFXClose to close Intel MediaSDK.
The AMD hardware coder, for carrying out H264 Video coding to the computer system for supporting AMD hardware encoding;
Specifically, as shown in figure 4, the AMD hardware coder includes AMD hardware coder initialization submodule, AMD hard
Part encoder encoding submodule and AMD hardware coder close submodule, in which:
The AMD hardware coder initialization submodule specifically includes DLL load for initializing AMD hardware coder
Submodule, interface creation submodule, parameter setting submodule and AMD parameter acquisition submodule, in which:
The DLL load submodule is for loading amf-core-windesktop32.dll and amf-component-
vce-windesktop32.dll;
The interface creation submodule is for calling AMFCreateContext to create AMFContext interface, and calling
AMFCreateComponent creates AMFComponent interface,
The parameter setting submodule is used to call the SetProperty of AMFComponent interface that relevant coding is arranged
Parameter, the coding parameter include resolution ratio, code rate and frame per second;And the Init method of AMFComponent interface is called to complete to compile
The initialization of code device;
The AMD parameter acquisition submodule is used to call the GetProperty method of AMFComponent interface, obtains
The H264 sequence sets parameter and PPSH264 image set parameter of AMF_VIDEO_ENCODER_EXTRADATA enumeration type;
The AMD hardware coder encoding submodule is used to carry out H264 coding to video, specifically includes video surface point
Submodule and AMD byte stream acquisition submodule are submitted in sub-module, video surface, in which:
The video surface distribution submodule is used to call the AllocSurface method of AMFContext interface to distribute and uses
To receive the video surface of image to be encoded;
The video surface submits submodule for calling the SubmitInput method of AMFComponent interface, will be upper
The video surface generated in step is submitted in encoder;
The AMD byte stream acquisition submodule is used to call the QueryOutput method of AMFComponent interface, obtains
Byte stream after encoder coding;
The AMD hardware coder closes submodule, for calling AMFComponent interface when stopping coding
Terminate method closes encoder, carries out the release of resource.
The Nvidia hardware coder, for carrying out H264 video to the computer system for supporting Nvidia hardware encoding
Coding.
Specifically, as shown in figure 5, the Nvidia hardware coder includes Nvidia hardware coder initialization submodule
Block, Nvidia hardware coder encoding submodule and Nvidia hardware coder close submodule, in which:
The Nvidia hardware coder initialization submodule specifically includes volume for initializing Nvidia hardware coder
Code context initialization submodule, Nvidia parameter setting submodule, Nvidia parameter acquisition submodule and the creation of video memory surface
Submodule, in which:
For the coding environment initialization submodule for loading nvcuda.dll and nvEncodeAPI.dll, initialization must
The environment wanted;And the NvEncodeAPICreateInstance method of nvEncodeAPI module is called to create NV_ENCODE_
API_FUNCTION_LIST structure;And cuCtxCreate_v2 interface is called to create context environmental;
The Nvidia parameter setting submodule is for calling nvEncOpenEncodeSessionEx method creation coding
Device session, and call nvEncGetEncodePresetConfig to be configured coder parameters, and call
The initialization of nvEncInitializeEncoder completion encoder;
The Nvidia parameter acquisition submodule is NV_ for calling nvEncGetSequenceParams to obtain type
The H264 sequence sets parameter and PPSH264 image set parameter of ENC_SEQUENCE_PARAM_PAYLOAD_VER;
The video memory surface creation submodule is for calling nvEncCreateInputBuffer creation to be used to receive wait compile
The video memory surface of the image data of code, and call nvEncCreateBitstreamBuffer creation coding output storing data;
The Nvidia hardware coder encoding submodule is used to carry out H264 coding to video, specifically includes filling coding
Image submodule, encoding submodule and Nvidia byte stream acquisition submodule, in which:
The filling coded image submodule is for calling nvEncLockInputBuffer to lock above-mentioned video memory surface wound
The video memory surface of submodule creation is built, and fills coded image;And call nvEncUnlockInputBuffer to the video memory table
Face is unlocked;
The encoding submodule is for calling nvEncEncodePicture to be encoded;
What the Nvidia byte stream acquisition submodule was used to return after calling nvEncLockBitstream to obtain coding
Byte stream calls nvEncUnlockBitstream to discharge byte stream after doing corresponding processing;
The Nvidia hardware coder closes submodule, for calling when stopping coding
NvEncDestroyEncoder closes encoder, and cuCtxDestroy_v2 is called to discharge current environment context.
Specifically, hardware differences can be shielded by providing unified interface in embodiments of the present invention, by such as
UML (Unified Modeling Language) class figure shown in fig. 6 describes the technical program to the hardware encodings of three large platforms encapsulation and right
The encapsulation of libx264 software encoder.
It is corresponding with AmdEncoder, NvidiaEncoder, QsvEncoder and X264Encoder, they respectively represent
AMD hardware coder, Nvidia hardware coder, Intel hardware coder and x264 software encoder, they inherit
From BaseEncoder interface, BaseEncoder interface inheritance is from IMediaEncoder interface, and IMediaEncoder is exactly
The final abstract interface that unitizes, method provided by the interface write exactly in figure including (Open, open encoder,
Close closes encoder, Encode, coding etc.) specific interface is defined as follows:
1, IMediaFile interface
(1.1)bool Open(char*filepath,bool write)
File is opened, filepath parameter represents file path, it can is the file path of local disk, is also possible to
The RTMP agreement URL of RTMP: //XXX beginning, is also possible to RTSP: RTSP agreement URL, write the parameter generation of //XXX beginning
Table is to read file or written document, should be that should be true in coding.
(1.2)IMediaEncoder*CreateEncoder(CodecType type)
Encoder is created, parameter type is the type of encoder, and return value is IMediaEncoder interface
(1.3)bool WriteFileHeader()
Written document head includes SPS, PPS information of video encoder in file header, is used for decoder in multimedia file
Decoding
(1.4)bool WritePacket(IRawPacket*pkt)
For writing the byte stream after coding, byte stream can both be saved in local disk file by this method, can also be with
It is sent to RTMP server with RTMP agreement is crossed, the byte stream that will be write and relevant information are contained in parameter pkt
(1.5)int64_t SizeWritten()
For returning to the byte number write
(1.6)void SetMetaDataInformation(const std::string&key,const std::
string&value)
MetaData (metadata) information for being arranged in file
(1.7)bool Close()
File, the RTMP agreement that the file write can be closed or sent are closed, and closes H264 encoder, is discharged
Resource
2, CodecType enumeration type
(2.1)CT_VIDEOBEST
The hardware coder for automatically selecting support is represented, can be used to judge that current system supports which type of hardware to compile
Code device
(2.2)CT_X264
Represent libx264 software encoder
(2.3)CT_QSV264
Represent Intel hardware coder
(2.4)CT_AMD264
Code AMD platform hardware encoder
3IMediaEncoder interface
The interface is obtained by the CreateEncoder interface of IMediaFile
(3.1)bool Open(int width,int height,int bitrate)
Encoder is opened, parameter width is the width of video to be encoded, and height is the height of video to be encoded, and bitrate is
The code rate of coding
(3.2)bool Close()
Close encoder
(3.3)IRawPacket*Encode(uint8_t*pixels[3],int64_t stamp)
Coded image, parameter pixles are the image to be encoded, and stamp is scramble time stamp, return to IRawPacket and connect
Mouthful
(3.4)CodecType GetCodecType()
Obtain the type of encoder
4, IRawPacket interface
The interface is the H264 byte stream interface returned when IMediaEncoder is encoded
(4.1)uint8_t*Buffer()
H264 byte streambuf is decoded for decoder
(4.2)int Size()
H264 byte stream buffer size is decoded for decoder
(4.3)int64_t Pts()
Video frame Presentation Time Stamp is decoded for decoder
(4.4)int64_t Dts()
Screen frame decoding time stamp
(4.5)bool Keyframe()
Judge whether it is key frame
(4.6)Release()
Discharge the interface
5 modules export function
IMediaFile*CreateMediaFile(ContainerFormat cf)
The function is that the DLL in the ylmediaengine module of the technical solution exports function, for creating one
IMediaFile interface can create hardware H264 encoder by the IMediaFile interface of the creation.
It is illustrated how below with reference to a specific example hard using above system progress H264 in actual computer system
Part coding, such as by the IMediaFile interface, be broadcast live in platform (such as companion is broadcast live in bucket fish TV) and use in a kind of game
The interface carries out hardware encoding and the picture after coding is pushed to bucket fish TV server, is broadcast live, specifically, realizes step
It is as follows:
(6.1) CreateMediaFile function creation IMediaFile interface is called;
(6.2) it calls the CreateEncoder method of IMediaFile interface to create IMediaEncoder interface, is passed to
Parameter be CT_VIDEOBEST;
(6.3) the GetCodecType method of the IMediaEncoder interface in calling in step, obtains current encoder
Type.When returning to CT_QSV264, system supports Intel hardware encoding, and system supports AMD hardware to compile when returning to CT_AMD264
Code, system supports Nvidia hardware encoding when returning to CT_NV264, and system does not support any hardware encoding when returning to CT_X264;
Such as:
When system video card type are as follows: when Nvidia 740 type of GeForce, support Nvidia hardware encoding;When system is aobvious
Card Type are as follows: when Intel (R) HD Graphics, support Intel hardware encoding;When system video card type are as follows: AMD Radeon
When HD 7700Series, AMD hardware encoding is supported
(6.4) encoder is initialized
Select resolution ratio for 1920*1080, frame number selects 25FPS, code rate selection 1600, and encoder selects AMD hardware to compile
Code.
By the IMediaDecoder interface created in step (6.2), call the Open method of the interface, and by these
Parameter is passed in Open method, carries out the initialization of encoder;
(6.5) RTMP server is connected
After initializing encoder success, the Open method of IMediaFile is called, connects RTMP server;
(6.6) H264 information are sent to RTMP server
After connecting the success of RTMP server, the WriteFileHeader method of IMediaFile is called, the head of video is believed
The RTMP server sent is ceased, is decoded for player;
(6.7) it is encoded
After above procedure all succeeds, the Encode method of IMediaEncoder can be called, companion's preview window will be broadcast live
Picture in mouthful is encoded, and returns to IRawPacket interface;
(6.8) pushing video stream
By the IRawPacket interface returned in upper step, the WritePacket method of IMediaFile is called, will be encoded
The RTMP server of pushing video streaming afterwards.
By above step, just realizes using hardware encoding in the embodiment of the present invention, image is pushed to RTMP service
The process that device is broadcast live.
As it will be easily appreciated by one skilled in the art that the foregoing is merely illustrative of the preferred embodiments of the present invention, not to
The limitation present invention, any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should all include
Within protection scope of the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201510887873.3A CN105491387B (en) | 2015-12-04 | 2015-12-04 | A H264 Hardware Encoding System Based on Intel, AMD and Nvidia |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201510887873.3A CN105491387B (en) | 2015-12-04 | 2015-12-04 | A H264 Hardware Encoding System Based on Intel, AMD and Nvidia |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN105491387A CN105491387A (en) | 2016-04-13 |
| CN105491387B true CN105491387B (en) | 2019-06-21 |
Family
ID=55678054
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201510887873.3A Expired - Fee Related CN105491387B (en) | 2015-12-04 | 2015-12-04 | A H264 Hardware Encoding System Based on Intel, AMD and Nvidia |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN105491387B (en) |
Families Citing this family (10)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106231319A (en) * | 2016-07-14 | 2016-12-14 | 观止云(北京)信息技术有限公司 | A kind of method alignd frame by frame based on software and hardware combining |
| CN110022478A (en) * | 2018-01-09 | 2019-07-16 | 武汉斗鱼网络科技有限公司 | A kind of H265 hardware encoding method and live streaming platform based on Intel SkyLake integrated graphics card |
| CN110022480B (en) * | 2018-01-09 | 2022-03-25 | 武汉斗鱼网络科技有限公司 | A H265 hardware encoding method and live broadcast platform based on AMD graphics card |
| CN110022479A (en) * | 2018-01-09 | 2019-07-16 | 武汉斗鱼网络科技有限公司 | A kind of H265 hardware encoding method and live streaming platform based on Nvidia Maxwell2 video card |
| CN110008102B (en) * | 2019-04-10 | 2020-03-06 | 苏州浪潮智能科技有限公司 | Server performance testing method and system based on intelligent video application |
| CN110147248B (en) * | 2019-04-19 | 2021-06-29 | 中国科学院计算技术研究所 | Single-precision matrix multiplication optimization method and system accelerated by AMD GPU assembly instructions |
| CN116074544A (en) * | 2022-11-15 | 2023-05-05 | 深圳壹秘科技有限公司 | Multi-platform live broadcast method, system, equipment and medium |
| CN116016992A (en) * | 2022-12-30 | 2023-04-25 | 联想(北京)有限公司 | A kind of encoding method and device |
| CN119342229A (en) * | 2024-12-20 | 2025-01-21 | 杭州阿启视科技有限公司 | Adaptive GPU scheduling method for video encoding and decoding applicable to multiple GPU types |
| CN119629392A (en) * | 2025-02-08 | 2025-03-14 | 杭州宇泛智能科技股份有限公司 | Audio and video encoding and decoding system and method compatible with heterogeneous chip platforms |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101490992A (en) * | 2006-07-14 | 2009-07-22 | 高通股份有限公司 | Encoder initialization and communications |
| CN102724049A (en) * | 2012-07-02 | 2012-10-10 | 上海市共进通信技术有限公司 | Method for realizing cross-hardware-platform compatible passive optical network device multicast function |
| CN103617191A (en) * | 2013-11-07 | 2014-03-05 | 北京奇虎科技有限公司 | Browser and method for rendering same by means of hardware acceleration |
| CN104049970A (en) * | 2014-05-29 | 2014-09-17 | 汉柏科技有限公司 | Automatic identifying method and system for framework and platform at user mode |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8359573B2 (en) * | 2008-09-30 | 2013-01-22 | Rockwell Automation Technologies, Inc. | Application builder for industrial automation |
| CN103686164A (en) * | 2012-09-06 | 2014-03-26 | 腾讯科技(深圳)有限公司 | Method, system and module for self-adaptive hardware coding and decoding |
| CN104581015A (en) * | 2013-10-21 | 2015-04-29 | 北京航天长峰科技工业集团有限公司 | Video monitoring method for enabling encoders of multiple brands to be compatible |
| CN104980752B (en) * | 2015-06-11 | 2018-10-02 | 武汉大千信息技术有限公司 | The method and system of multichannel self-adaptive parallel transcoding are realized using CPU and GPU |
-
2015
- 2015-12-04 CN CN201510887873.3A patent/CN105491387B/en not_active Expired - Fee Related
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101490992A (en) * | 2006-07-14 | 2009-07-22 | 高通股份有限公司 | Encoder initialization and communications |
| CN102724049A (en) * | 2012-07-02 | 2012-10-10 | 上海市共进通信技术有限公司 | Method for realizing cross-hardware-platform compatible passive optical network device multicast function |
| CN103617191A (en) * | 2013-11-07 | 2014-03-05 | 北京奇虎科技有限公司 | Browser and method for rendering same by means of hardware acceleration |
| CN104049970A (en) * | 2014-05-29 | 2014-09-17 | 汉柏科技有限公司 | Automatic identifying method and system for framework and platform at user mode |
Also Published As
| Publication number | Publication date |
|---|---|
| CN105491387A (en) | 2016-04-13 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN105491387B (en) | A H264 Hardware Encoding System Based on Intel, AMD and Nvidia | |
| US11805304B2 (en) | Method, device, and computer program for generating timed media data | |
| CN113196784B (en) | Point cloud coding structure | |
| TWI887437B (en) | Media access function for scene descriptions | |
| CN105430408B (en) | A kind of H264 hardware decoding system based on tri- platform of Intel, AMD and Nvidia | |
| JP6339012B2 (en) | Transmission of reconstructed data in a layered signal quality hierarchy | |
| CN104144349B (en) | SPICE coding and decoding videos extended method and system based on H264 | |
| CN109155875A (en) | Method, apparatus and computer program for encapsulating and parsing timed media data | |
| CN109891893A (en) | It is derived in Streaming Media and with signal sending zone and viewport | |
| CN113457160A (en) | Data processing method and device, electronic equipment and computer readable storage medium | |
| CN117176715A (en) | Point cloud encoding and decoding methods, devices, computer-readable media and electronic equipment | |
| US20240046562A1 (en) | Information processing device and method | |
| US10997795B2 (en) | Method and apparatus for processing three dimensional object image using point cloud data | |
| CN112188285A (en) | Video transcoding method, device, system and storage medium | |
| US20170163990A1 (en) | Video transcoding method and system | |
| CN105263021B (en) | A kind of HEVC video encoding/decoding methods based on UVD | |
| CN105376585A (en) | Method for improving video transmission speed by frame image combination | |
| KR20240155209A (en) | Video processing method, device and medium | |
| Adeyemi-Ejeye et al. | 4kUHD H264 wireless live video streaming using CUDA | |
| Gudumasu et al. | Adaptive Streaming of Visual Volumetric Video-based Coding Media | |
| Kammachi‐Sreedhar et al. | Omnidirectional video delivery with decoder instance reduction | |
| WO2023175243A1 (en) | A method, an apparatus and a computer program product for video encoding and video decoding | |
| Deneke et al. | Integration of dataflow components within a legacy video transcoding framework | |
| Ngo | Panorama Video Tiling: Efficient Processing and Encoding of Tiles | |
| Horta | Platforms for Handling and Development of Audiovisual Data |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20190621 |
|
| CF01 | Termination of patent right due to non-payment of annual fee |