API Definitions
Visionular’s Aurora5 HEVC encoder supports input of 8/10-bit YUV400/420/422/444 image/video and outputs a bitstream compliant with the HEVC/H.265 standard.
Note:
- The encoding interface is defined in the file
wz265enc.h. - For related integration examples, please refer to
wz265_sample_encoder.corwz265_sample_encoder_mvhevc.cif you are using stereoscopic content. - The encoder is built from WZ265EncConfig which exposes the core parameters needed to set up the encoder.
- Further parameters can be passed in an extra configuration string by wz265-params.
Generate Default Configuration Parameters
_h_dll_export int wz265_param_default(WZ265EncConfig *pConfig, int preset, int tune);
- Function: Generates default configuration parameters for
pConfigby specifyingpresetandtune, wherepresetandtuneare integers. - Return Value: Error code.
- Parameters:
pConfig: Pointer to basic configuration parameters.preset: Specifies the speed level.tune: Specifies the application scenario.
Create Encoder
_h_dll_export void *wz265_encoder_open(WZ265EncConfig *pCfg, int *errorCode);
- Function: Creates an encoder instance.
- Return Value: Pointer to the encoder instance.
-
Parameters:
pCfg: Basic configuration parameters for the encoder.errorCode: Returns the error code.
-
Note: Before calling this interface, the incoming
pCfgmust first be filled with default values usingwz265_param_default, and then some parameters can be configured as needed.
Change Encoding Configuration Parameters
_h_dll_export int wz265_encoder_reconfig(void *pEncoder, WZ265EncConfig *pCfg);
- Function: Adjusts the encoder parameters.
- Return Value: Error code.
- Parameters:
pEncoder: Pointer to the encoder instance.pCfg: Basic configuration parameters for the encoder.
- Note: Parameters that can be reset by wz265_encoder_rencofig are listed in the table - WZ265EncConfig.
Destroy Encoder
_h_dll_export void wz265_encoder_close(void *pEncoder);
- Function: Destroys an encoder instance.
- Return Value: None.
- Parameters:
pEncoder: Pointer to the encoder instance.
Encode a Frame of Image
_h_dll_export int wz265_encoder_frame(void *pEncoder, WZ265Nal **pNals, int *iNalCount, WZ265Picture *pInpic, WZ265Picture *pOutpic);
- Function: Encodes one frame of YUV image.
- Return Value: Error code, 0 indicates normal operation.
-
Parameters:
pEncoder: Pointer to the encoder instance.pNals: Pointer to the NAL units generated by encoding, wherepNals[i]represents the pointer to number i NAL unit.iNalCount: Number of NAL units generated by encoding.pInpic: Pointer to the input YUV image structure, which is not synchronized with the outputpNals.pOutpic: Pointer to the output image frame, which serves as auxiliary information for the outputpNals, synchronized withpNals. It is only for reference and can be discarded without affecting normal encoding.
-
Note:
- When compressing multiview content, i.e. when using MV-HEVC, left and right views are submitted as frames to the encoder. These views are expected to be presented in an interleaved fashion, so that even numbered pictures are associated with the left view and odd numbered pictures are associated with the right view. Accordingly, a stereoscopic video file with
Nspatial frames, needs to have2 x Nviews. To let the Aurora5 SDK be able to distinguish between left and right views, the fieldviewIdneeds to be set according to the following convention: - Left view :
viewId=0 - Right view :
viewId=1 - As mentioned, for multiview content, the
wz265_encoder_frameis expected to have itspInpicwith the following sequence ofviewIdvalues:viewId=0;viewId=1;...viewId=0;viewId=1; - The API will return an error if such interleaved order is violated. The Aurora5 encoder's API uses the recommended values and conventions of the Apple Stereo Video Interoperability profile. If the user wants to switch the order above, i.e. having right views submitted first, then the input
viewIdvalues need to be modified accordingly. Also, theleft_view_idandright_view_idvalues in thethreeDimRefDisplaysInfofield of theWZ265EncConfigobject need to be modified so that the left and right views will now have value 1 and 0, respectively.
- When compressing multiview content, i.e. when using MV-HEVC, left and right views are submitted as frames to the encoder. These views are expected to be presented in an interleaved fashion, so that even numbered pictures are associated with the left view and odd numbered pictures are associated with the right view. Accordingly, a stereoscopic video file with
Encode Parameter Sets (VPS, SPS, PPS, etc. headers)
_h_dll_export int wz265_encode_headers(void *pEncoder, WZ265Nal **pNals, int *iNalCount);
- Function: Encodes the VPS/SPS/PPS parameter sets.
- Return Value: Error code, 0 indicates normal operation.
- Parameters:
pEncoder: Pointer to the encoder instance.pNals: Pointer to the NAL units generated by encoding, wherepNals[i]represents the pointer to number i NAL unit.iNalCount: Number of NAL units generated by encoding.
Key Frame Request
_h_dll_export void wz265_keyframe_request(void *pEncoder);
- Function: Initiates a request for encoding a key frame; the encoder will encode a key frame during the next call to
WZ265EncoderEncodeFrame. - Return Value: None.
- Parameters:
pEncoder: Pointer to the encoder instance.
- Note:
- Aurora5 provides two methods for forcing keyframes:
- Method 1 : Call the API of
wz265_keyframe_request. - Method 2 : Before calling
wz265_encoder_framefor the current frame, setinpic.iSliceType = 2. - These two methods have differences:
- In scenarios where latency is not allowed or zero latency is required, both methods produce the same result.
- In live streaming or on-demand scenarios where latency is allowed,
wz265_keyframe_requestsets the next available keyframe, taking into account the encoder's lookahead delay and GOP structure (i.e., the number of B-frames). A keyframe will only be inserted when the delay and GOP structure conditions are met. On the other hand, setting iSliceType = 2 for the current frame will force it to be a keyframe, and the original GOP structure will be adjusted accordingly. - Please choose the optimal keyframe insertion strategy according to your practical application requirements!
Query Delayed Frames Count
_h_dll_export int wz265_encoder_delayed_frames(void *pEncoder);
- Function: Queries the number of frames that the encoder has yet to encode, only used at the end of a sequence. If the return value is greater than 0, it indicates that there are still delayed frames that have not been encoded, and
wz265_encoder_framemust continue to be called until all frames are encoded. - Return Value: Number of delayed frames; 0 indicates all frames have been encoded.
- Parameters:
pEncoder: Pointer to the encoder instance.