GPUOpen-LibrariesAndSDKs / AMF

The Advanced Media Framework (AMF) SDK provides developers with optimal access to AMD devices for multimedia processing
Other
587 stars 148 forks source link

Slice based on number of bits/bytes #421

Closed Shhiva5 closed 3 months ago

Shhiva5 commented 10 months ago

AMF version : 1.4.30 AMD GPU Hardware : Radeon RX 6800 XT Encoder : HEVC

To set number of slices per frame : res = pEncoder->SetProperty(AMF_VIDEO_ENCODER_HEVC_SLICES_PER_FRAME, numOfSlicesPerFrame);

"AMF_VIDEO_ENCODER_HEVC_SLICES_PER_FRAME" is used to set number of slices per frame. Is there any way to set slices based on number of bits? If this is possible, please suggest the parameter to be used.

rhutsAMD commented 10 months ago

AMF_VIDEO_ENCODER_HEVC_SLICES_PER_FRAME is the only parameter that controls the number of slices for the HEVC encoder.

Do you intend to try to keep the size of each slice constant which results in larger compressed frames being split into more slices than smaller compressed frames? Could you please clarify your use case so that we may consider it for possible future improvements?

Shhiva5 commented 10 months ago

Hi, sorry for delayed response. Yes. We are exploring a mode in which all slices are of similar size. Larger compressed frames should be split into more number of slices. We are potentially working on an application which would need equivalent packet sizes for streaming. It would be great if this mode can be supported. Other thing on this is, if this mode is supported, we would need an mechanism to detect last slice of the frame from encoder return codes. This will be needed because the number of slices for any frame will be variable for this mode of operation.

rhutsAMD commented 10 months ago

Thank you for providing the additional information. AMF does not currently have a mode to output slices of a constant size but we will consider this for the future.

AMF does currently provide a way to identify the last slice. AMF_VIDEO_ENCODER_OUTPUT_BUFFER_TYPE will identify the last slice in the frame after slice output has been enabled with AMF_VIDEO_ENCODER_OUTPUT_MODE.

Additionally and somewhat related, AMF does have the ability to limit frame size using AMF_VIDEO_ENCODER_MAX_AU_SIZE to keep the network bitrate constant. This is not the same as limiting the size of each slice which you were originally looking for but it may help.