Voice et bot modif
This commit is contained in:
parent
189d56026b
commit
7333a22bcd
10774 changed files with 634644 additions and 933308 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
venv/lib/python3.12/site-packages/av/subtitles/codeccontext.abi3.so
Executable file
BIN
venv/lib/python3.12/site-packages/av/subtitles/codeccontext.abi3.so
Executable file
Binary file not shown.
Binary file not shown.
|
|
@ -4,4 +4,5 @@ from av.packet cimport Packet
|
|||
|
||||
cdef class SubtitleCodecContext(CodecContext):
|
||||
cdef bint subtitle_header_set
|
||||
cpdef decode(self, Packet packet=?)
|
||||
cpdef decode2(self, Packet packet)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
import cython
|
||||
from cython.cimports import libav as lib
|
||||
from cython.cimports.av.bytesource import ByteSource, bytesource
|
||||
from cython.cimports.av.buffer import ByteSource, bytesource
|
||||
from cython.cimports.av.codec.context import CodecContext
|
||||
from cython.cimports.av.error import err_check
|
||||
from cython.cimports.av.packet import Packet
|
||||
from cython.cimports.av.subtitles.subtitle import SubtitleProxy, SubtitleSet
|
||||
from cython.cimports.cpython.bytes import PyBytes_FromStringAndSize
|
||||
from cython.cimports.libc.string import memcpy, strlen
|
||||
from cython.cimports.libc.string import memcpy
|
||||
|
||||
|
||||
@cython.final
|
||||
@cython.cclass
|
||||
class SubtitleCodecContext(CodecContext):
|
||||
@property
|
||||
|
|
@ -64,28 +66,16 @@ class SubtitleCodecContext(CodecContext):
|
|||
|
||||
self.open(strict=False)
|
||||
|
||||
# Calculate buffer size from subtitle text length
|
||||
buf_size: cython.size_t = 0
|
||||
i: cython.uint
|
||||
for i in range(subtitle.proxy.struct.num_rects):
|
||||
rect = subtitle.proxy.struct.rects[i]
|
||||
if rect.ass != cython.NULL:
|
||||
buf_size += strlen(rect.ass)
|
||||
if rect.text != cython.NULL:
|
||||
buf_size += strlen(rect.text)
|
||||
buf_size += 1024 # padding for format overhead
|
||||
|
||||
buf: cython.p_uchar = cython.cast(cython.p_uchar, lib.av_malloc(buf_size))
|
||||
buf: cython.p_uchar = cython.cast(cython.p_uchar, lib.av_malloc(1024 * 1024))
|
||||
if buf == cython.NULL:
|
||||
raise MemoryError("Failed to allocate subtitle encode buffer")
|
||||
raise MemoryError()
|
||||
|
||||
ret: cython.int = lib.avcodec_encode_subtitle(
|
||||
self.ptr,
|
||||
buf,
|
||||
buf_size,
|
||||
1024 * 1024,
|
||||
cython.address(subtitle.proxy.struct),
|
||||
)
|
||||
|
||||
if ret < 0:
|
||||
lib.av_free(buf)
|
||||
err_check(ret, "avcodec_encode_subtitle()")
|
||||
|
|
@ -93,7 +83,6 @@ class SubtitleCodecContext(CodecContext):
|
|||
packet: Packet = Packet(ret)
|
||||
memcpy(packet.ptr.data, buf, ret)
|
||||
lib.av_free(buf)
|
||||
|
||||
packet.ptr.pts = subtitle.proxy.struct.pts
|
||||
packet.ptr.dts = subtitle.proxy.struct.pts
|
||||
packet.ptr.duration = (
|
||||
|
|
@ -103,11 +92,17 @@ class SubtitleCodecContext(CodecContext):
|
|||
|
||||
return packet
|
||||
|
||||
@cython.cfunc
|
||||
def _send_packet_and_recv(self, packet: Packet | None):
|
||||
@cython.ccall
|
||||
def decode(self, packet: Packet | None = None):
|
||||
"""Decode a subtitle packet, returning a list of :class:`.Subtitle` objects
|
||||
if a subtitle was decoded, or an empty list otherwise."""
|
||||
if not self.codec.ptr:
|
||||
raise ValueError("cannot decode unknown codec")
|
||||
|
||||
if packet is None:
|
||||
raise RuntimeError("packet cannot be None")
|
||||
|
||||
self.open(strict=False)
|
||||
proxy: SubtitleProxy = SubtitleProxy()
|
||||
got_frame: cython.int = 0
|
||||
|
||||
|
|
@ -121,7 +116,7 @@ class SubtitleCodecContext(CodecContext):
|
|||
)
|
||||
|
||||
if got_frame:
|
||||
return SubtitleSet(proxy)
|
||||
return list(SubtitleSet(proxy))
|
||||
return []
|
||||
|
||||
@cython.ccall
|
||||
|
|
|
|||
BIN
venv/lib/python3.12/site-packages/av/subtitles/stream.abi3.so
Executable file
BIN
venv/lib/python3.12/site-packages/av/subtitles/stream.abi3.so
Executable file
Binary file not shown.
Binary file not shown.
|
|
@ -3,6 +3,7 @@ from cython.cimports.av.packet import Packet
|
|||
from cython.cimports.av.stream import Stream
|
||||
|
||||
|
||||
@cython.final
|
||||
@cython.cclass
|
||||
class SubtitleStream(Stream):
|
||||
def __getattr__(self, name):
|
||||
|
|
|
|||
BIN
venv/lib/python3.12/site-packages/av/subtitles/subtitle.abi3.so
Executable file
BIN
venv/lib/python3.12/site-packages/av/subtitles/subtitle.abi3.so
Executable file
Binary file not shown.
Binary file not shown.
|
|
@ -4,12 +4,10 @@ cimport libav as lib
|
|||
cdef class SubtitleProxy:
|
||||
cdef lib.AVSubtitle struct
|
||||
|
||||
|
||||
cdef class SubtitleSet:
|
||||
cdef SubtitleProxy proxy
|
||||
cdef readonly tuple rects
|
||||
|
||||
|
||||
cdef class Subtitle:
|
||||
cdef SubtitleProxy proxy
|
||||
cdef lib.AVSubtitleRect *ptr
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
import cython
|
||||
from cython.cimports.cpython import PyBuffer_FillInfo, PyBytes_FromString
|
||||
from cython.cimports.libc.stdint import int64_t, uint64_t
|
||||
from cython.cimports.libc.string import memcpy, strlen
|
||||
from cython.cimports.libc.string import memcpy
|
||||
|
||||
|
||||
@cython.final
|
||||
@cython.cclass
|
||||
class SubtitleProxy:
|
||||
def __dealloc__(self):
|
||||
lib.avsubtitle_free(cython.address(self.struct))
|
||||
|
||||
|
||||
_cinit_bypass_sentinel = object()
|
||||
_cinit_bypass_sentinel = cython.declare(object, object())
|
||||
|
||||
|
||||
@cython.final
|
||||
@cython.cclass
|
||||
class SubtitleSet:
|
||||
"""
|
||||
|
|
@ -48,21 +49,18 @@ class SubtitleSet:
|
|||
"""
|
||||
Create a SubtitleSet for encoding.
|
||||
|
||||
Args:
|
||||
text: The subtitle text in ASS dialogue format
|
||||
(e.g. b"0,0,Default,,0,0,0,,Hello World")
|
||||
start: Start display time as offset from pts (typically 0)
|
||||
end: End display time as offset from pts (i.e., duration)
|
||||
pts: Presentation timestamp in stream time_base units
|
||||
subtitle_format: Subtitle format (default 1 for text)
|
||||
:param text: The subtitle text in ASS dialogue format
|
||||
(e.g. ``b"0,0,Default,,0,0,0,,Hello World"``)
|
||||
:param start: Start display time as offset from pts (typically 0)
|
||||
:param end: End display time as offset from pts (i.e., duration)
|
||||
:param pts: Presentation timestamp in stream time_base units
|
||||
:param subtitle_format: Subtitle format (default 1 for text)
|
||||
:return: A SubtitleSet ready for encoding
|
||||
|
||||
Note:
|
||||
.. note::
|
||||
All timing values should be in stream time_base units.
|
||||
For MKV (time_base=1/1000), units are milliseconds.
|
||||
For MP4 (time_base=1/1000000), units are microseconds.
|
||||
|
||||
Returns:
|
||||
A SubtitleSet ready for encoding
|
||||
"""
|
||||
subset: SubtitleSet = SubtitleSet(_cinit_bypass_sentinel)
|
||||
|
||||
|
|
@ -208,6 +206,7 @@ class Subtitle:
|
|||
return f"<av.{self.__class__.__name__} at 0x{id(self):x}>"
|
||||
|
||||
|
||||
@cython.final
|
||||
@cython.cclass
|
||||
class BitmapSubtitle(Subtitle):
|
||||
def __cinit__(self, subtitle: SubtitleSet, index: cython.int):
|
||||
|
|
@ -251,6 +250,7 @@ class BitmapSubtitle(Subtitle):
|
|||
return self.planes[i]
|
||||
|
||||
|
||||
@cython.final
|
||||
@cython.cclass
|
||||
class BitmapSubtitlePlane:
|
||||
def __cinit__(self, subtitle: BitmapSubtitle, index: cython.int):
|
||||
|
|
@ -269,6 +269,7 @@ class BitmapSubtitlePlane:
|
|||
PyBuffer_FillInfo(view, self, self._buffer, self.buffer_size, 0, flags)
|
||||
|
||||
|
||||
@cython.final
|
||||
@cython.cclass
|
||||
class AssSubtitle(Subtitle):
|
||||
"""
|
||||
|
|
@ -293,10 +294,10 @@ class AssSubtitle(Subtitle):
|
|||
Extract the dialogue from the ass format. Strip comments.
|
||||
"""
|
||||
comma_count: cython.short = 0
|
||||
i: uint64_t = 0
|
||||
i: cython.Py_ssize_t = 0
|
||||
state: cython.bint = False
|
||||
ass_text: bytes = self.ass
|
||||
char, next_char = cython.declare(cython.char)
|
||||
char, next_char = cython.declare(cython.uchar)
|
||||
result: bytearray = bytearray()
|
||||
text_len: cython.Py_ssize_t = len(ass_text)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue