
    \j-                        d dl Z d dlZ ej                  ee j                  dk(  rdnd      Z ej                  e e             Zej                  de	j                  defd       Zej                  ej                   G d d	                    Zy)
    Nlittlelebec_formatreturnc                 >    | dk  ryt        t              }| |_        |S )z2Get an AudioFormat without going through a string.r   N)AudioFormat_cinit_bypass_sentinel
sample_fmt)r   formats     B/root/.hermes/venv/lib/python3.12/site-packages/av/audio/format.pyget_audio_formatr      s&     !|%&<=F FM    c                       e Zd ZdZd Zd Zed        Zed        Zed        Z	ed        Z
ed        Zed	        Zed
        Zed        Zy)r	   zDescriptor of audio formats.c                     |t         u ry t        |t              r%t        j                  t        |      j
                  }nt        j                  |      }|dk  rt        d|      || _        y )Nr   zNot a sample format: )	r
   
isinstancer	   cythoncastr   libav_get_sample_fmt
ValueError)selfnamer   s      r   	__cinit__zAudioFormat.__cinit__   sa    )) dK([$7BBJ..t4J>4TH=>>$r   c                 "    d| j                    dS )Nz<av.AudioFormat >)r   r   s    r   __repr__zAudioFormat.__repr__+   s    !$))A..r   c                 @    t         j                  | j                        S )zcCanonical name of the sample format.

        >>> AudioFormat('s16p').name
        's16p'

        )r   av_get_sample_fmt_namer   r   s    r   r   zAudioFormat.name.   s     ))$//::r   c                 @    t         j                  | j                        S )zVNumber of bytes per sample.

        >>> AudioFormat('s16p').bytes
        2

        r   av_get_bytes_per_sampler   r   s    r   byteszAudioFormat.bytes8   s     **4??;;r   c                 F    t         j                  | j                        dz  S )zUNumber of bits per sample.

        >>> AudioFormat('s16p').bits
        16

           r"   r   s    r   bitszAudioFormat.bitsB   s     **4??;q@@r   c                 R    t        t        j                  | j                              S )zSIs this a planar format?

        Strictly opposite of :attr:`is_packed`.

        )boolr   av_sample_fmt_is_planarr   r   s    r   	is_planarzAudioFormat.is_planarL   s     C//@AAr   c                 B    t         j                  | j                         S )zSIs this a packed format?

        Strictly opposite of :attr:`is_planar`.

        )r   r*   r   r   s    r   	is_packedzAudioFormat.is_packedU   s     ..t???r   c                 n    | j                   r| S t        t        j                  | j                              S )zThe planar variant of this format.

        Is itself when planar:

        >>> fmt = AudioFormat('s16p')
        >>> fmt.planar is fmt
        True

        )r+   r   r   av_get_planar_sample_fmtr   r   s    r   planarzAudioFormat.planar^   *     >>K < <T__ MNNr   c                 n    | j                   r| S t        t        j                  | j                              S )zThe packed variant of this format.

        Is itself when packed:

        >>> fmt = AudioFormat('s16')
        >>> fmt.packed is fmt
        True

        )r-   r   r   av_get_packed_sample_fmtr   r   s    r   packedzAudioFormat.packedm   r1   r   c                    | j                   rt        d      | j                  t        j                  k(  ry| j                  t        j
                  k(  r	dt        z   S | j                  t        j                  k(  r	dt        z   S | j                  t        j                  k(  r	dt        z   S | j                  t        j                  k(  r	dt        z   S t        d      )zThe name of a :class:`ContainerFormat` which directly accepts this data.

        :raises ValueError: when planar, since there are no such containers.

        zno planar container formatsu8s16s32f32f64zunknown layout)
r+   r   r   r   AV_SAMPLE_FMT_U8AV_SAMPLE_FMT_S16container_format_postfixAV_SAMPLE_FMT_S32AV_SAMPLE_FMT_FLTAV_SAMPLE_FMT_DBLr   s    r   container_namezAudioFormat.container_name|   s     >>:;;??c222__ 5 55333__ 5 55333__ 5 55333__ 5 55333)**r   N)__name__
__module____qualname____doc__r   r   propertyr   r$   r'   r+   r-   r0   r4   rA    r   r   r	   r	      s     '%/ ; ; < < A A B B @ @ O O O O + +r   r	   )sysr   declarestr	byteorderr=   objectr
   cfuncr   AVSampleFormatr	   r   finalcclassrG   r   r   <module>rQ      s    
 )6>>(*  (9  s11 k   x+ x+  x+r   