Ë
    AôjO(  ã                   óŒ  — d dl Z d dlmZ d dlZd dlmc mZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ  G d„ de«      Z G d	„ d
e«      Z ej$                  e e«       «      Z ej$                  e e j*                  «       «      Zej.                  dej0                  ej2                  ej4                        defd„«       Zej:                  ej<                   G d„ d«      «       «       Zej>                  d„ «       Z ej:                  ej<                   G d„ d«      «       «       Z!ej:                  ej<                   G d„ d«      «       «       Z"y)é    N)ÚIntEnum)ÚCodec)Ú
Dictionary)Ú	err_check)Úget_video_formatc                   ót  — e Zd Zej                  Zej                  Zej                  Z	ej                  Zej                  Zej                  Zej                   Zej$                  Zej(                  Zej,                  Zej0                  Zej4                  Zej8                  Zej<                  Zej@                  Z!y)ÚHWDeviceTypeN)"Ú__name__Ú
__module__Ú__qualname__ÚlibÚAV_HWDEVICE_TYPE_NONEÚnoneÚAV_HWDEVICE_TYPE_VDPAUÚvdpauÚAV_HWDEVICE_TYPE_CUDAÚcudaÚAV_HWDEVICE_TYPE_VAAPIÚvaapiÚAV_HWDEVICE_TYPE_DXVA2Údxva2ÚAV_HWDEVICE_TYPE_QSVÚqsvÚAV_HWDEVICE_TYPE_VIDEOTOOLBOXÚvideotoolboxÚAV_HWDEVICE_TYPE_D3D11VAÚd3d11vaÚAV_HWDEVICE_TYPE_DRMÚdrmÚAV_HWDEVICE_TYPE_OPENCLÚopenclÚAV_HWDEVICE_TYPE_MEDIACODECÚ
mediacodecÚAV_HWDEVICE_TYPE_VULKANÚvulkanÚAV_HWDEVICE_TYPE_D3D12VAÚd3d12vaÚAV_HWDEVICE_TYPE_AMFÚamfÚAV_HWDEVICE_TYPE_OHCODECÚohcodec© ó    úa/var/www/html/academy/tools/voices/clone/fw-venv/lib/python3.12/site-packages/av/codec/hwaccel.pyr	   r	      s§   „ Ø×$Ñ$€DØ×&Ñ&€EØ×$Ñ$€DØ×&Ñ&€EØ×&Ñ&€EØ
×
"Ñ
"€CØ×4Ñ4€LØ×*Ñ*€GØ
×
"Ñ
"€CØ×(Ñ(€FØ×0Ñ0€JØ×(Ñ(€FØ×*Ñ*€GØ
×
"Ñ
"€CØ×*Ñ*�Gr-   r	   c                   óp   — e Zd ZdZej
                  Zej                  Zej                  Z
ej                  Zy)ÚHWConfigMethodr   N)r
   r   r   r   r   Ú'AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTXÚhw_device_ctxÚ'AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTXÚhw_frame_ctxÚ"AV_CODEC_HW_CONFIG_METHOD_INTERNALÚinternalÚ AV_CODEC_HW_CONFIG_METHOD_AD_HOCÚad_hocr,   r-   r.   r0   r0      s8   „ Ø€Dà×3Ñ3ð ð ×>Ñ>€LØ×5Ñ5€HØ×1Ñ1�Fr-   r0   ÚptrÚreturnc                 ó  — 	 t         t        j                  t        j                  | «         S # t        $ r Y nw xY wt        t        «      }|j                  | «       |t         t        j                  t        j                  | «      <   |S ©N)Ú_singletonsÚcythonÚcastÚ
Py_ssize_tÚKeyErrorÚHWConfigÚ_cinit_sentinelÚ_init)r9   Úconfigs     r.   Úwrap_hwconfigrF   ,   sk   € ðÜœ6Ÿ;™;¤v×'8Ñ'8¸#Ó>Ñ?Ð?øÜò Ùðúä¤Ó0€FØ
‡L�L�ÔØ7=„K”—‘œF×-Ñ-¨sÓ3Ñ4Ø€Ms   ‚*- ­	9¸9c                   óâ   — e Zd Zd„ Zej
                  dej                  ej                  ej                        dej                  fd„«       Zd„ Zed„ «       Zed„ «       Zed„ «       Zed	„ «       Zy
)rB   c                 ó*   — |t         urt        d«      ‚y )NzCannot instantiate CodecContext)rC   ÚRuntimeError)ÚselfÚsentinels     r.   Ú__init__zHWConfig.__init__;   s   € Øœ?Ñ*ÜÐ@ÓAÐAð +r-   r9   r:   c                 ó   — || _         y r<   )r9   )rJ   r9   s     r.   rD   zHWConfig._init?   s   € ð ˆ�r-   c                 ó:  — d| j                   j                  › dt        j                  | j                  «      › d| j
                  r| j
                  j                  nd › d| j                  › dt        j                  t        j                  | j                  «      d›d�S )Nz<av.z device_type=z format=z is_supported=z at 0xÚxú>)Ú	__class__r
   r   Úav_hwdevice_get_type_nameÚdevice_typeÚformatÚnameÚis_supportedr>   r?   r@   r9   ©rJ   s    r.   Ú__repr__zHWConfig.__repr__E   s�   € à�4—>‘>×*Ñ*Ð+ð ,Ü×8Ñ8¸×9IÑ9IÓJÐKð LØ*.¯+ª+�d—k‘k×&Ò&¸4Ð@ð AØ ×-Ñ-Ð.¨f´V·[±[Ä×ARÑARÐTX×T\ÑT\Ó5]Ð^_Ð4`Ð`aðcð	
r-   c                 ó@   — t        | j                  j                  «      S r<   )r	   r9   rS   rW   s    r.   rS   zHWConfig.device_typeM   s   € ä˜DŸH™H×0Ñ0Ó1Ð1r-   c                 óD   — t        | j                  j                  dd«      S )Nr   )r   r9   Úpix_fmtrW   s    r.   rT   zHWConfig.formatQ   s   € ä §¡× 0Ñ 0°!°QÓ7Ð7r-   c                 ó@   — t        | j                  j                  «      S r<   )r0   r9   ÚmethodsrW   s    r.   r]   zHWConfig.methodsU   s   € ä˜dŸh™h×.Ñ.Ó/Ð/r-   c                 ób   — t        | j                  j                  t        j                  z  «      S r<   )Úboolr9   r]   r   r1   rW   s    r.   rV   zHWConfig.is_supportedY   s"   € ä�D—H‘H×$Ñ$¤s×'RÑ'RÑRÓSÐSr-   N)r
   r   r   rL   r>   ÚcfuncÚpointerÚconstr   ÚAVCodecHWConfigÚvoidrD   rX   ÚpropertyrS   rT   r]   rV   r,   r-   r.   rB   rB   8   s£   „ òBð ‡\�\ðØ—>‘> &§,¡,¨s×/BÑ/BÑ"CÑDðà	�‰òó ðò

ð ñ2ó ð2ð ñ8ó ð8ð ñ0ó ð0ð ñTó ñTr-   rB   c                  óÚ   — g } t         j                  }	 t        j                  |«      }|t         j                  k(  r	 | S | j                  t        j                  t        |«      «      «       ŒY)zkReturn the names of the hardware device types FFmpeg was built with,
    e.g. ``["cuda", "videotoolbox"]``.)r   r   Úav_hwdevice_iterate_typesÚappendrR   r	   )ÚresultrO   s     r.   Úhwdevices_availablerj   ^   s_   € ð €FÜ×5Ñ5€AØ
Ü×)Ñ)¨!Ó,ˆØ”×)Ñ)Ò)Øà€Mð 	�‰”c×3Ñ3´LÀ³OÓDÔEð	 r-   c                   ó4   — e Zd ZdZd„ Zdd„Zed„ «       Zd„ Zy)ÚHWDevicea÷  HWDevice(device_type, device=None, options=None, flags=None)

    A hardware device context which can be shared by components such as filter
    graphs. The underlying FFmpeg buffer is reference counted; consumers take
    their own references and this object never exposes the raw pointer.

    :param device_type: The kind of device, e.g. ``"cuda"``, ``"vaapi"`` or
        ``"vulkan"``. See :func:`hwdevices_available` for the types supported by
        the loaded FFmpeg.
    :type device_type: str or HWDeviceType
    :param str device: An optional device identifier. Uses the default device if
        ``None``.
    :param dict options: Options passed to ``av_hwdevice_ctx_create``.
    :param int flags: Flags passed to ``av_hwdevice_ctx_create``.
    c                 ó.   — t         j                  | _        y r<   )r>   ÚNULLr9   rW   s    r.   Ú	__cinit__zHWDevice.__cinit__   s   € Ü—;‘;ˆ�r-   Nc           	      óT  — t        |t        «      rt        |«      | _        n�t        |t        «      rNt        t        j                  |«      «      | _        | j                  t
        j                  k(  r1t        d|› �«      ‚t        |t        «      r|| _        nt        d«      ‚| j                  t
        j                  k(  rt        d«      ‚|si n
t        |«      | _        |€dn|| _        t        j                  }|€d n|› }|r|j                  «       }|}t!        | j                  «      }t#        t        j$                  t        j&                  | j(                  «      t        j*                  t
        j,                  | j                  «      ||j(                  | j                  «      «       y )NzUnknown hardware device type: z6device_type must be a string, integer, or HWDeviceTypez%Hardware device type cannot be 'none'r   )Ú
isinstancer	   ÚintÚ_device_typeÚstrr   Úav_hwdevice_find_type_by_namer   Ú
ValueErrorÚ	TypeErrorÚdictÚoptionsÚflagsr>   rn   Úencoder   r   Úav_hwdevice_ctx_createÚaddressr9   r?   ÚAVHWDeviceType)	rJ   rS   Údevicery   rz   Úc_deviceÚdevice_nameÚdevice_bytesÚ	c_optionss	            r.   rL   zHWDevice.__init__‚   sG  € Ü�k¤<Ô0Ü # KÓ 0ˆDÕÜ˜¤SÔ)Ü #¤C×$EÑ$EÀkÓ$RÓ SˆDÔØ× Ñ ¤C×$=Ñ$=Ò=Ü Ð#AÀ+ÀÐ!OÓPÐPÜ˜¤SÔ)Ø +ˆDÕäÐTÓUÐUà×Ñ¤× 9Ñ 9Ò9ÜÐDÓEÐEá!(‘r¬d°7«mˆŒØ˜-‘Q¨UˆŒ
ä"(§+¡+ˆØ$˜n‘d°V°HˆÙØ&×-Ñ-Ó/ˆLØ#ˆHÜ *¨4¯<©<Ó 8ˆ	äÜ×&Ñ&Ü—‘˜tŸx™xÓ(Ü—‘œC×.Ñ.°×0AÑ0AÓBØØ—‘Ø—
‘
óõ	
r-   c                 ó,   — t        | j                  «      S r<   )r	   rs   rW   s    r.   rS   zHWDevice.device_type¥   s   € ä˜D×-Ñ-Ó.Ð.r-   c                 ó‚   — | j                   r3t        j                  t        j                  | j                   «      «       y y r<   ©r9   r   Úav_buffer_unrefr>   r}   rW   s    r.   Ú__dealloc__zHWDevice.__dealloc__©   ó)   € Ø�8Š8Ü×Ñ¤§¡¨t¯x©xÓ 8Õ9ð r-   )NNN)	r
   r   r   Ú__doc__ro   rL   re   rS   rˆ   r,   r-   r.   rl   rl   l   s+   „ ñò ó!
ðF ñ/ó ð/ó:r-   rl   c                   óP   — e Zd ZdZ	 	 	 	 	 d
d„Zddedefd„Zddededefd„Z	d	„ Z
y)ÚHWAccelaç  HWAccel(device_type, device=None, allow_software_fallback=True, options=None, flags=None, is_hw_owned=False)

    Settings for hardware-accelerated decoding and encoding. Pass an instance to
    :func:`av.open` to decode on the device, or to
    :meth:`OutputContainer.add_stream <av.container.OutputContainer.add_stream>`
    to encode on it.

    :param device_type: The kind of device, e.g. ``"cuda"``, ``"vaapi"``,
        ``"videotoolbox"``. See :func:`hwdevices_available` for the types
        supported by the loaded FFmpeg.
    :type device_type: str or HWDeviceType
    :param str device: An optional device identifier, e.g. a DRI render node path
        (``"/dev/dri/renderD128"``) for VAAPI or a device index (``"1"``) for CUDA.
        Uses the default device if ``None``.
    :param bool allow_software_fallback: Whether decoding falls back to a software
        decoder when the hardware decoder cannot handle the stream.
    :param dict options: Options passed to ``av_hwdevice_ctx_create``.
    :param int flags: Flags passed to ``av_hwdevice_ctx_create``.
    :param bool is_hw_owned: If True, decoded frames stay on the device (for
        consumption via DLPack, for example) instead of being downloaded to
        system memory.
    Nc                 ó‚  — t        |t        «      r|| _        nWt        |t        «      r$t	        t        j                  |«      «      | _        n#t        |t        «      r|| _        nt        d«      ‚|| _        d| _	        | j                  t        j                  k(  r|rt	        |«      | _	        |€d n|› | _        || _        |si n
t        |«      | _        | j                  t        j                  k(  r(| j                  r| j                  j                  dd«       |sdn|| _        t"        j$                  | _        d | _        y )NzUnknown type for device_typer   Úprimary_ctxÚ1)rq   r	   rs   rt   rr   r   ru   rv   Úis_hw_ownedÚ	device_idr   Ú_deviceÚallow_software_fallbackrx   ry   Ú
setdefaultrz   r>   rn   r9   rE   )rJ   rS   r   r“   ry   rz   r�   s          r.   rL   zHWAccel.__init__È   sù   € ô �k¤<Ô0Ø +ˆDÕÜ˜¤SÔ)Ü #¤C×$EÑ$EÀkÓ$RÓ SˆDÕÜ˜¤SÔ)Ø +ˆDÕäÐ;Ó<Ð<à&ˆÔØˆŒØ×Ñ¤× 1Ñ 1Ò1±fÜ  ›[ˆDŒNà%˜~‘t°f°XˆŒØ'>ˆÔ$á!(‘r¬d°7«mˆŒØ×Ñ¤× 1Ñ 1Ò1°d×6FÒ6FØ�L‰L×#Ñ# M°3Ô7Ù#‘Q¨ˆŒ
Ü—;‘;ˆŒØˆ�r-   ÚcodecÚfor_encodingc           	      ó„  — t         j                  }|r|t         j                  z  }|j                  D ]C  }|j                  j
                  |z  sŒ| j                  r|j                  | j                  k7  rŒC n t        d|› �«      ‚|| _	        t        j                  }| j                  r| j                  j                  «       }|}t        | j                  «      }t!        t        j"                  t        j$                  | j                  «      |j                  j                  ||j                  | j&                  «      «       y )Nz!No supported hardware config for )r   r1   r3   Úhardware_configsr9   r]   rs   rS   ÚNotImplementedErrorrE   r>   rn   r’   r{   r   ry   r   r|   r}   rz   )rJ   r•   r–   Úsupported_methodsrE   r€   r‚   rƒ   s           r.   Ú_initialize_hw_contextzHWAccel._initialize_hw_contexté   s
  € ô ),×(SÑ(SÐÙØ¤×!LÑ!LÑLÐð ×,Ñ,ò 	SˆFØ—J‘J×&Ñ&Ð):Ò:ØØ× Ò  V×%7Ñ%7¸4×;LÑ;LÒ%LØÙð	Sô &Ð(IÈ%ÈÐ&QÓRÐRàˆŒÜ"(§+¡+ˆØ�<Š<ØŸ<™<×.Ñ.Ó0ˆLØ#ˆHÜ *¨4¯<©<Ó 8ˆ	äÜ×&Ñ&Ü—‘˜tŸx™xÓ(Ø—
‘
×&Ñ&ØØ—‘Ø—
‘
óõ	
r-   r:   c                 óô   — | j                   rt        d«      ‚t        | j                  | j                  | j
                  | j                  | j                  | j                  ¬«      }|j                  ||¬«       |S )z>Create a new hardware accelerator context with the given codecz$Hardware context already initialized)rS   r   r“   ry   rz   r�   )r–   )
r9   rI   rŒ   rs   r’   r“   ry   rz   r�   r›   )rJ   r•   r–   Úrets       r.   ÚcreatezHWAccel.create  si   € à�8Š8ÜÐEÓFÐFäØ×)Ñ)Ø—<‘<Ø$(×$@Ñ$@Ø—L‘LØ—*‘*Ø×(Ñ(ô
ˆð 	×"Ñ" 5°|Ð"ÔDØˆ
r-   c                 ó‚   — | j                   r3t        j                  t        j                  | j                   «      «       y y r<   r†   rW   s    r.   rˆ   zHWAccel.__dealloc__  r‰   r-   )NTNNF)F)r
   r   r   rŠ   rL   r   r_   r›   rŒ   rž   rˆ   r,   r-   r.   rŒ   rŒ   ®   sQ   „ ñð4 Ø $ØØØóñB!
¨Eð !
Àó !
ñF˜Eð °ð À'ó ó :r-   rŒ   )#ÚweakrefÚenumr   r>   Úcython.cimports.libavÚcimportsÚlibavr   Úcython.cimports.av.codec.codecr   Úcython.cimports.av.dictionaryr   Úcython.cimports.av.errorr   Úcython.cimports.av.video.formatr   r	   r0   ÚdeclareÚobjectrC   ÚWeakValueDictionaryr=   r`   ra   rb   rc   rB   rF   ÚfinalÚcclassÚccallrj   rl   rŒ   r,   r-   r.   ú<module>r¯      sE  ðÛ Ý ã ß #Ð #Ý 0Ý 4Ý .Ý <ô+�7ô +ô$2�Wô 2ð !�&—.‘. ©«Ó2€Øˆf�n‰n˜VÐ%@ W×%@Ñ%@Ó%BÓC€ð ‡�ð�v—~‘~ f§l¡l°3×3FÑ3FÑ&GÑHð ÈXò ó ðð ‡�Ø‡�÷!Tð !Tó ó ð!TðH ‡�ñ
ó ð
ð ‡�Ø‡�÷=:ð =:ó ó ð=:ð@ ‡�Ø‡�÷n:ð n:ó ó ñn:r-   