Compare commits

..

5 Commits

Author SHA1 Message Date
51fa25809d add x265 submodule 2025-10-04 04:54:22 +02:00
de6c3a4e7f x264 submodule 2025-10-04 04:52:37 +02:00
2ed4c7b6d8 ffmpeg submodule 2025-10-04 04:33:40 +02:00
4afaf287bb avframe fields 2025-10-04 04:27:51 +02:00
5825c67f30 cleanup 2025-10-04 04:27:24 +02:00
6 changed files with 47 additions and 16 deletions

12
.gitmodules vendored Normal file
View File

@ -0,0 +1,12 @@
[submodule "ffmpeg"]
path = ffmpeg
url = https://git.ffmpeg.org/ffmpeg.git
branch = release/8.0
[submodule "codecs/x264"]
path = codecs/x264
url = https://code.videolan.org/videolan/x264.git
branch = stable
[submodule "codecs/x265"]
path = codecs/x265
url = https://bitbucket.org/multicoreware/x265_git.git
branch = Release_4.1

1
codecs/x264 Submodule

Submodule codecs/x264 added at b35605ace3

1
codecs/x265 Submodule

Submodule codecs/x265 added at 32e25ffcf8

1
ffmpeg Submodule

Submodule ffmpeg added at d8605a6b55

View File

@ -38,7 +38,13 @@ class Decoder:
if self._context:
libav.codec_free_context(self._context)
def _receive(self):
def decode(self, packet):
if not self._context:
return None
errcode = libav.codec_send_packet(self._context, packet)
if errcode < 0:
errstring = libav.strerror(errcode)
raise Exception(f"Failed to send packet: {errstring}")
frames = []
while True:
frame = Frame()
@ -50,12 +56,3 @@ class Decoder:
raise Exception(f"Failed to receive frame: {errstring}")
frames.append(frame)
return frames
def decode(self, packet):
if not self._context:
return None
errcode = libav.codec_send_packet(self._context, packet)
if errcode < 0:
errstring = libav.strerror(errcode)
raise Exception(f"Failed to send packet: {errstring}")
return self._receive()

View File

@ -40,8 +40,32 @@ AVMEDIA_TYPE_DATA = 2
AVMEDIA_TYPE_SUBTITLE = 3
AVMEDIA_TYPE_ATTACHMENT = 4
AV_NUM_DATA_POINTERS = 8
c_uint8_p = ctypes.POINTER(ctypes.c_uint8)
c_uint8_pp = ctypes.POINTER(c_uint8_p)
class AVRational(ctypes.Structure):
_fields_ = [
("num", ctypes.c_int),
("den", ctypes.c_int)]
class AVFrame(ctypes.Structure):
pass
_fields_ = [
("data", c_uint8_p * AV_NUM_DATA_POINTERS),
("linesize", ctypes.c_int * AV_NUM_DATA_POINTERS),
("extended_data", c_uint8_pp),
("width", ctypes.c_int),
("height", ctypes.c_int),
("nb_samples", ctypes.c_int),
("format", ctypes.c_int),
("key_frame", ctypes.c_int),
("pict_type", ctypes.c_int),
("sample_aspect_ratio", AVRational),
("pts", ctypes.c_int64),
("pkt_dts", ctypes.c_int64),
("time_base", AVRational)]
# ...
AVFrame_p = ctypes.POINTER(AVFrame)
AVFrame_pp = ctypes.POINTER(AVFrame_p)
@ -51,11 +75,6 @@ class AVCodecParameters(ctypes.Structure):
AVCodecParameters_p = ctypes.POINTER(AVCodecParameters)
class AVRational(ctypes.Structure):
_fields_ = [
("num", ctypes.c_int),
("den", ctypes.c_int)]
class AVStream(ctypes.Structure):
_fields_ = [
("av_class", ctypes.c_void_p),