
    \j                         d dl Z d dlmZ d dlmZmZ d dlmZm	Z	 d dl
mZmZ d dlmZ d dlmZ e j"                  e j$                   G d d	e                    Zy)
    N)libav)AudioFormatget_audio_format)
AudioFramealloc_audio_frame)AudioLayoutget_audio_layout)Frame)Packetc                      e Zd Zej                  dedz  defd       Zej                  defd       Zej                  dede	fd       Z
ed	        Zed
        Zej                  dej                  fd       Zed        Zej                  d        Zed        Zed        Zej                  d        Zed        Zej                  d        Zy)AudioCodecContextinput_frameNreturnc                    |}| j                   j                  j                  t        j                  z  }| j
                  sTt        | j                  | j                  | j                   j                  |rd n| j                   j                        | _        | j
                  j                  |      }||j                  d        |S )N)formatlayoutrate
frame_size)ptrcodeccapabilitieslib AV_CODEC_CAP_VARIABLE_FRAME_SIZE	resamplerAudioResamplerr   r   sample_rater   resampleappend)selfr   frameallow_var_frame_sizeframess        H/root/.hermes/venv/lib/python3.12/site-packages/av/audio/codeccontext.py_prepare_frames_for_encodez,AudioCodecContext._prepare_frames_for_encode   s    #.HHNN''#*N*NN 	 ~~+{{{{XX))#74TXX=P=P	DN ((/MM$    c                     t               S N)r   r   s    r#   _alloc_next_framez#AudioCodecContext._alloc_next_frame#   s     ""r%   r    packetc                 V    t         j                  | ||       |}|j                          y r'   )CodecContext_setup_decoded_frame_init_user_attributes)r   r    r*   aframes       r#   r-   z&AudioCodecContext._setup_decoded_frame'   s%    ))$v>"$$&r%   c                 .    | j                   j                  S )zV
        Number of samples per channel in an audio frame.

        :type: int
        )r   r   r(   s    r#   r   zAudioCodecContext.frame_size-   s     xx"""r%   c                 .    | j                   j                  S )z[
        Sample rate of the audio data, in samples per second.

        :type: int
        r   r   r(   s    r#   r   zAudioCodecContext.sample_rate6   s     xx###r%   valuec                 &    || j                   _        y r'   r2   r   r3   s     r#   r   zAudioCodecContext.sample_rate?   s    $r%   c                     | j                   S )z%Another name for :attr:`sample_rate`.r   r(   s    r#   r   zAudioCodecContext.rateC   s     r%   c                     || _         y r'   r7   r5   s     r#   r   zAudioCodecContext.rateH   s
     r%   c                 .    | j                   j                  S r'   )r   nb_channelsr(   s    r#   channelszAudioCodecContext.channelsL   s    {{&&&r%   c                 @    t        | j                  j                        S )zG
        The audio channel layout.

        :type: AudioLayout
        )r	   r   	ch_layoutr(   s    r#   r   zAudioCodecContext.layoutP   s       2 233r%   c                 P    t        |      }|j                  | j                  _        y r'   )r   r   r   r=   )r   r3   r   s      r#   r   zAudioCodecContext.layoutY   s    )%0#]]r%   c                 @    t        | j                  j                        S )zF
        The audio sample format.

        :type: AudioFormat
        )r   r   
sample_fmtr(   s    r#   r   zAudioCodecContext.format^   s       3 344r%   c                 P    t        |      }|j                  | j                  _        y r'   )r   r@   r   )r   r3   r   s      r#   r   zAudioCodecContext.formatg   s    )%0$//r%   )__name__
__module____qualname__cythoncfuncr
   listr$   r)   r   r-   propertyr   r   setterintr   r;   r   r    r%   r#   r   r   
   sV    \\edl t  * \\#5 # # \\'% ' ' '
 # # $ $ % % %     
[[! ! ' ' 4 4 ]]+ + 5 5 ]]0 0r%   r   )rE   cython.cimportsr   r   cython.cimports.av.audio.formatr   r   cython.cimports.av.audio.framer   r   cython.cimports.av.audio.layoutr   r	   cython.cimports.av.framer
   cython.cimports.av.packetr   finalcclassr,   r   rK   r%   r#   <module>rT      sH     ( I H I * , ^0 ^0  ^0r%   