GPUOpen-LibrariesAndSDKs / AMF

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

Access to more encoding Parameters #106

Closed Xaymar closed 7 years ago

Xaymar commented 7 years ago

As an ex-user of the OpenVideo Encoder based OBS Classic fork, I can't help but wonder what happened to all the options - are they no longer available? Additionally, would it be possible to expose more parameters to developers?

OpenVideo Encoder had:

Additionally the following are logged to AMF Trace but not exposed or changable:

A lot of these map to the original OpenVideo Encoder settings, why have they been omitted from Media SDK and Advanced Media Framework SDK? Can and will they be exposed again?

Xaymar commented 7 years ago

After some digging into the history, i found out that the OVE headers perfectly match what AMF logs to the trace, which means that the OpenVideo Encoder parameters still exist but stopped being exposed for some odd reason. I don't know what reasoning would have led to that choice.

Parameters

CreateEncoder

Encode Mode

Apparently OVE had both a "full" AVC encoding mode and an entry only encoding mode. According to wikipedia on VCE, the entropy-only mode is part of AMF App SDK but I could not find it there.

pictureFormat

This actually has two values, 1 being NV12 (AMF default) and 2 being YV12 (flipped NV12). Not necessarily needed to be exposed, or maybe already is.

level, profile

Exposed by AMF.

requestedPriority

Allowed to choose between Normal and Low Latency encoding, which i believe i exposed through Usage now - except with the downside that Usage Low Latency breaks streaming while requestedPriority Low Latency did not.

Rate Control

encRateControlMethod, encRateControlTargetBitRate, encRateControlPeakBitRate, encRateControlFrameRateNumerator, encRateControlFrameRateDenominator, encVBVBufferSize, encVBVLevelValue, encQP_I, encQP_P, encQP_B

Exposed by AMF.

encGOPSize

GOP Size that was removed for creating "too complex logic", whatever that means. Technically implemented by anything that forced I-Frames at specific intervals. x264 implements dynamically (I-Frames inserted at scenecuts and large changes that P/B-Frames can't easily cover), nvenc does the same.

encRCOptions

Bit 0 is what FrameSkipping is now, bits 1-31 have no known meaning. Partially exposed?

Picture Control

CABACEnable, loopFilterDisable, encIDRPeriod, encHeaderInsertionSpacing, encCropLeftOffset, encCropRightOffset, encCropTopOffset, encCropBottomOffset

Exposed by AMF.

encNumMBsPerSlice, encNumSlicesPerFrame

Exposed but not documented or explained how these work. Best guess so far resulting in drastic quality flickering or outright just black frames.

useConstrainedIntraPred

Forces the use of constrained intra prediction when set to 1.

CABACIDC

"cabac_init_id", three possible values (0, 1, 2). No information about what each one does or how it works.

encLFBetaOffset

"Loop filter control, slice_beta_offset (N.B. only used if deblocking filter is not disabled, and there is no div2 as defined in the h264 bitstream syntax)"

encLFAlphaC0Offset

"Loop filter control, slice_alpha_c0_offset (N.B. only used if deblocking filter is not disabled, and there is no div2 as defined in the h264 bitstream syntax)"

encIPicPeriod

The before mentioned I-Picture Period that can control GOP Size, which can also be manually implemented by forcing individual frame picture types.

encForceIntraRefresh

"1 serves to load intra refresh bitmap from address force_intra_refresh_bitmap_mc_addr when equal to 1, 3 also loads dirty clean bitmap on top of the intra refresh". Seems to be useless?

encForceIMBPeriod

Spacing between Intra-Refresh Macroblocks, shifts intra-refreshed mbs by set value if encForceIntraRefresh is 2.

encInsertVUIParam

Insert VUI params in SPS, iirc exposed.

encInsertSEIMsg

Apparently used to control what contents the SEI message had. Exact effects unknown. Bits 1,2,3 were always set in any OVE using application.

encSliceMode

Slicing mode, 1 or 2 as options. Already exposed, but not documented enough. Earlier testing kinda revealed 1=Row, 2=Column, at least it seemed to behave like that.

encSliceArgument

Parameter for the above. "either number of bytes per slice or number of MBs per slice"

Motion Estimation

motionEstHalfPixel, motionEstQuarterPixel

Exposed by AMF.

IMEDecimationSearch

disableFavorPMVPoint

forceZeroPointCenter

LSMVert (lsmVert, lsmVert5, lsmVert3, lsmVert1)

Luma Search Window in Macroblocks as a Vector, OVE had either 5x3, 9x5 or 13x7 as options. lsmVert was the actual property and lsmVert5, lsmVert3 & lsmVert1 were used to further control it. lsmVert5, lsmVert3, lsmVert1 seemed to have vanished in later OVE versions.

encSearchRangeX, encSearchRangeY

Limitation for "Forward Prediction" Motion Vector range for performance. Definitely should be exposed.

encSearch1RangeX, encSearch1RangeY

Limitation for forward prediction of 2nd Motion Vector range for performance. Also should be exposed.

disable16x16Frame1

Apparently used by B-Frames only, limits 16x16 block sizes on first frame after I-Frame?

disableSATD

Disables SATD (sum absolute transform distortion) cost calculation, switching to SAD (sum of absolute differences) cost only. Potentially useful to be exposed.

enableAMD

"FME advanced mode decision".

encIMESkipX, encIMESkipY

"Sub-sample Search window", potentially improves per-pixel movement detection.

encDisableSubMode

Disables some internal ME features, comment only says "FME".

encEnImeOverwDisSubm

Enable overwriting of fme_disable_submode (encDisableSubMode) in IME with enable mode number, equal to ime_overw_dis_subm_no (only 8x8 and above could be enabled). Don't see any immediate uses for this.

encImeOverwDisSubmNo

Numbers of mode IME will pick if en_ime_overw_dis_subm (encEnImeOverwDisSubm) is equal to 1.

encIME2SearchRangeX, encIME2SearchRangeY

IME additional search window size, X limit 1-4, Y limit none. Limit is +- from center point.

"RDO"

encDisableTbePredIFrame, encDisableTbePredPFrame

Disable prediction modes for I/P Frames,

useFmeInterpolY

zero_residues_luma. Useful for lossless perhaps?

useFmeInterpolUV

zero_residues_chroma. Useful for lossless perhaps?

enc16x16CostAdv

encSkipCostAdv

encForce16x16skip

Xaymar commented 7 years ago

Something of note is that i also found what Quality Presets did back in OVE days, the new ones are only minimally different:

Presets (OVE)

All (overridden by individual presets)

Speed

Balanced

Quality

Presets (AMF)

All

Speed

Balanced

Quality

MikhailAMD commented 7 years ago

OpenVideo (Decoder and Encoder) APIs are retired and removed from the driver. The fact that internal parameters visible in AMF logging have the same names as parameters in old headers means a little. AMF public parameters is what Codec team approved for safe usage with modern drivers. If a particular feature from OVE is missing in AMF and is really useful I can put a request to expose it and the codec team will consider the request.

Xaymar commented 7 years ago

Well then this is the official request for the following parameters to be able to fine-tune Quality Presets to the end hardware of the actual users. I'd like to see the following exposed directly in the future:

If possible, it would also be nice to be able to tell VCE/HEVC encoding one or two regions of interest in order to improve encoding efficiency. HEVC encoding (when software is used) allows specifying this and it helps in bitrate constrained situations where the user knows what areas are important to the viewers.

Xaymar commented 7 years ago

Closing as I've been told a straight up no to this, even if it would benefit performance and quality.

Benman2785 commented 3 years ago

has something changed now in 2021? NVenc is going further ahead and AMD AMFenc needs improvement...