Skip to content

Commit c8c9076

Browse files
committed
VideoFrame: Don't need np_buffer
1 parent 5a65cd3 commit c8c9076

File tree

3 files changed

+3
-18
lines changed

3 files changed

+3
-18
lines changed

av/video/frame.pxd

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,14 @@ cdef class CudaContext:
1313
cdef dict _frames_cache
1414
cdef lib.AVBufferRef* _get_device_ref(self)
1515
cdef public lib.AVBufferRef* get_frames_ctx(
16-
self,
17-
lib.AVPixelFormat sw_fmt,
18-
int width,
19-
int height,
16+
self, lib.AVPixelFormat sw_fmt, int width, int height
2017
)
2118

2219
cdef class VideoFrame(Frame):
23-
# This is the buffer that is used to back everything in the AVFrame.
24-
# We don't ever actually access it directly.
25-
cdef uint8_t *_buffer
26-
cdef object _np_buffer
27-
cdef object _cuda_ctx
28-
20+
cdef CudaContext _cuda_ctx
2921
cdef VideoReformatter reformatter
3022
cdef readonly VideoFormat format
3123
cdef readonly int _device_id
32-
3324
cdef _init(self, lib.AVPixelFormat format, unsigned int width, unsigned int height)
3425
cdef _init_user_attributes(self)
3526
cpdef save(self, object filepath)

av/video/frame.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,7 @@ def _init_user_attributes(self):
403403
)
404404

405405
def __dealloc__(self):
406-
# The `self._buffer` member is only set if *we* allocated the buffer in `_init`,
407-
# as opposed to a buffer allocated by a decoder.
408406
lib.av_frame_unref(self.ptr)
409-
# Let go of the reference from the numpy buffers if we made one
410-
self._np_buffer = None
411407

412408
def __repr__(self):
413409
return (
@@ -1061,7 +1057,6 @@ def _image_fill_pointers_numpy(self, buffer, width, height, linesizes, format):
10611057
c_ptr: cython.pointer[uint8_t] = cython.cast(cython.pointer[uint8_t], c_data)
10621058
c_format: lib.AVPixelFormat = get_pix_fmt(format)
10631059
lib.av_frame_unref(self.ptr)
1064-
self._np_buffer = None
10651060

10661061
# Hold on to a reference for the numpy buffer so that it doesn't get accidentally garbage collected
10671062
self.ptr.format = c_format
@@ -1094,7 +1089,6 @@ def _image_fill_pointers_numpy(self, buffer, width, height, linesizes, format):
10941089
Py_DECREF(py_buf)
10951090
raise MemoryError("av_buffer_create failed")
10961091

1097-
self._np_buffer = buffer
10981092
self._init_user_attributes()
10991093

11001094
@staticmethod

av/video/frame.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,4 @@ class VideoFrame(Frame):
101101
device_id: int | None = None,
102102
primary_ctx: bool = True,
103103
cuda_context: CudaContext | None = None,
104-
) -> "VideoFrame": ...
104+
) -> VideoFrame: ...

0 commit comments

Comments
 (0)