[FFmpeg-devel] [PATCH v11 07/14] avcodec/vaapi_encode: extract the init and close function to base layer

Lynne dev at lynne.ee
Sat May 25 17:25:16 EEST 2024


On 25/05/2024 16:18, Sean McGovern wrote:
> Hi,
> 
> 
> On Sat, May 25, 2024, 09:07 Lynne via ffmpeg-devel <ffmpeg-devel at ffmpeg.org>
> wrote:
> 
>> On 25/05/2024 12:30, tong1.wu-at-intel.com at ffmpeg.org wrote:
>>> From: Tong Wu <tong1.wu at intel.com>
>>>
>>> Related parameters such as device context, frame context are also moved
>>> to base layer.
>>>
>>> Signed-off-by: Tong Wu <tong1.wu at intel.com>
>>> ---
>>>    libavcodec/hw_base_encode.c     | 49 ++++++++++++++++++
>>>    libavcodec/hw_base_encode.h     | 17 +++++++
>>>    libavcodec/vaapi_encode.c       | 90 +++++++++++----------------------
>>>    libavcodec/vaapi_encode.h       | 10 ----
>>>    libavcodec/vaapi_encode_av1.c   |  2 +-
>>>    libavcodec/vaapi_encode_h264.c  |  2 +-
>>>    libavcodec/vaapi_encode_h265.c  |  2 +-
>>>    libavcodec/vaapi_encode_mjpeg.c |  6 ++-
>>>    8 files changed, 102 insertions(+), 76 deletions(-)
>>>
>>> diff --git a/libavcodec/hw_base_encode.c b/libavcodec/hw_base_encode.c
>>> index 16afaa37be..c4789380b6 100644
>>> --- a/libavcodec/hw_base_encode.c
>>> +++ b/libavcodec/hw_base_encode.c
>>> @@ -592,3 +592,52 @@ end:
>>>
>>>        return 0;
>>>    }
>>> +
>>> +int ff_hw_base_encode_init(AVCodecContext *avctx)
>>> +{
>>> +    FFHWBaseEncodeContext *ctx = avctx->priv_data;
>>
>> This is the issue I was talking about, this requires that
>> FFHWBaseEncodeContext is always the main context.
>>
>> Could you change it so everything takes FFHWBaseEncodeContext as an
>> argument, rather than AVCodecContext (apart from where the function
>> absolutely must read some data from it)?
>>
> 
> Might this suggestion involve having to do some ugly down-casting?

Not at all. Instead of having this context as the main context, just 
make each encoder have its own context, where this structure is the only 
element.
Vulkan requires extra state, such as an execution context, function 
pointers from the loader, memory the encoder needs, which, rather than 
adding to this structure, would be better off being in its own context.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0xA2FEA5F03F034464.asc
Type: application/pgp-keys
Size: 624 bytes
Desc: OpenPGP public key
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240525/b5b6c30e/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 236 bytes
Desc: OpenPGP digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240525/b5b6c30e/attachment.sig>


More information about the ffmpeg-devel mailing list