
    ^j                         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 d dlmZ e j        e j         G d d                                  Ze j        d	efd
            Z e            ZdS )    N)Codec)	err_check)Packet)Stream)EAGAINc                       e Zd ZdZ	 	 d
deez  ez  dz  dedz  fdZd Ze	j
        ddedz  fd            Ze	j
        d	             ZdS )BitStreamFilterContextaa  
    Initializes a bitstream filter: a way to directly modify packet data.

    Wraps :ffmpeg:`AVBSFContext`

    :param in_stream: Defines the input codec for the bitfilter. A :class:`.Stream`
        copies the full input codec parameters, while a :class:`.Codec` or a codec-name
        ``str`` only pins the input codec, which is all a codec-specific filter (such as
        ``h264_mp4toannexb``) needs to initialize.
    :type in_stream: :class:`.Stream`, :class:`.Codec`, str, or None
    :param Stream out_stream: A stream whose codec is overwritten using the output parameters from the bitfilter.
    N	in_stream
out_streamc                 B   |}t           j        5  t          j        |t          j        | j                            }d d d            n# 1 swxY w Y   t          |           t          |t                    rut           j        5  t          j	        | j        j
        t          j        t          |          j        j                  }d d d            n# 1 swxY w Y   t          |           n^|\t          |t                    r|nt          |          }|j        j        | j        j
        _        |j        j        | j        j
        _        t           j        5  t          j        | j                  }d d d            n# 1 swxY w Y   t          |           |t           j        5  t          j	        |j        j        | j        j                  }d d d            n# 1 swxY w Y   t          |           t          j        |j        j        |j        j                   d S d S N)cythonnogillibav_bsf_list_parse_straddressptrr   
isinstancer   avcodec_parameters_copypar_incastcodecparr   idcodec_idtype
codec_typeav_bsf_initpar_outavcodec_parameters_to_contextcodec_context)selffilter_descriptionr
   r   
filter_strrescodecs          /data/video-pipeline/HaTramAudio/project/018-Hon-Uoc-Khong-Duoc-Phep-Yeu/work/asr-venv/lib/python3.11/site-packages/av/bitstream.py	__cinit__z BitStreamFilterContext.__cinit__   s    %7
\ 	R 	R+Jtx8P8PQQC	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R#i(( 	8  1HOV[%C%C%G%P                cNNNN" (	599O		uY?O?O  (-y|DHO$).DHO&\ 	, 	,/$(++C	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,#!  1N+TX-=                cNNN-(,jn.E     "!sH   -AAAACCCE<<F F $*GG!Gc                 n    | j         r-t          j        t          j        | j                              d S d S r   )r   r   av_bsf_freer   r   r!   s    r&   __dealloc__z"BitStreamFilterContext.__dealloc__D   s8    8 	6OFN484455555	6 	6    packetc                    t           j        5  t          j        | j        ||j        nt           j                  }ddd           n# 1 swxY w Y   t          |           g }	 t                      }t           j        5  t          j        | j        |j                  }ddd           n# 1 swxY w Y   |t           k    s|t          j
        k    r|S t          |           |r|S |                    |           )z
        Processes a packet based on the filter_description set during initialization.
        Multiple packets may be created.

        :type: list[Packet]
        N)r   r   r   av_bsf_send_packetr   NULLr   r   av_bsf_receive_packetr   AVERROR_EOFappend)r!   r-   r$   output
new_packets        r&   filterzBitStreamFilterContext.filterH   sx    \ 	 	((:&** C	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	#	&J J J/*.IIJ J J J J J J J J J J J J J J vg~~!7!7cNNN MM*%%%	&s#   .AAA> B**B.1B.c                 8    t          j        | j                   dS )z
        Reset the internal state of the filter.
        Should be called e.g. when seeking.
        Can be used to make the filter usable again after draining it with EOF marker packet.
        N)r   av_bsf_flushr   r*   s    r&   flushzBitStreamFilterContext.flushh   s     	"""""r,   )NNr   )__name__
__module____qualname____doc__r   r   strr'   r+   r   ccallr   r6   r9    r,   r&   r	   r	   
   s           26$(	( ( E>C'$.( TM	( ( ( (T6 6 6 \& &Vd] & & & \&> \# # \# # #r,   r	   returnc                      t                      } t          j        }	 t          j        t          j        |                    }|r|                     |j                   nnE| S r   )setr   r0   r   av_bsf_iterater   addname)namesopaquer   s      r&   get_filter_namesrI   r   s_    E"KF !7!788 	IIch Lr,   )r   cython.cimports.libavcimportslibavr   cython.cimports.av.codec.codecr   cython.cimports.av.errorr   cython.cimports.av.packetr   cython.cimports.av.streamr   cython.cimports.libc.errnor   finalcclassr	   cfuncrC   rI   bitstream_filters_availabler@   r,   r&   <module>rV      s    # # # # # # # # # 0 0 0 0 0 0 . . . . . . , , , , , , , , , , , , - - - - - - c# c# c# c# c# c# c#  c#L #     /.00   r,   