File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11cimport libav as lib
22
33
4+ cdef class IndexEntry:
5+ cdef lib.AVIndexEntry * ptr
6+ cdef _init(self , lib.AVIndexEntry * ptr)
7+
48cdef class IndexEntries:
59 cdef lib.AVStream * stream_ptr
610 cdef _init(self , lib.AVStream * ptr)
711
8-
912cdef IndexEntries wrap_index_entries(lib.AVStream * ptr)
Original file line number Diff line number Diff line change 11import cython
22import cython .cimports .libav as lib
3- from cython .cimports .av .indexentry import wrap_index_entry
43from cython .cimports .libc .stdint import int64_t
54
65_cinit_bypass_sentinel = cython .declare (object , object ())
76
87
8+ @cython .cfunc
9+ def wrap_index_entry (ptr : cython .pointer [lib .AVIndexEntry ]) -> IndexEntry :
10+ obj : IndexEntry = IndexEntry (_cinit_bypass_sentinel )
11+ obj ._init (ptr )
12+ return obj
13+
14+
15+ @cython .cclass
16+ class IndexEntry :
17+ """A single entry from a stream's index.
18+
19+ This is a thin wrapper around FFmpeg's ``AVIndexEntry``.
20+
21+ The exact meaning of the fields depends on the container/demuxer.
22+ """
23+
24+ def __cinit__ (self , sentinel ):
25+ if sentinel is not _cinit_bypass_sentinel :
26+ raise RuntimeError ("cannot manually instantiate IndexEntry" )
27+
28+ @cython .cfunc
29+ def _init (self , ptr : cython .pointer [lib .AVIndexEntry ]):
30+ self .ptr = ptr
31+
32+ def __repr__ (self ):
33+ return (
34+ f"<av.IndexEntry pos={ self .pos } timestamp={ self .timestamp } flags={ self .flags } "
35+ f"size={ self .size } min_distance={ self .min_distance } >"
36+ )
37+
38+ @property
39+ def pos (self ):
40+ return self .ptr .pos
41+
42+ @property
43+ def timestamp (self ):
44+ return self .ptr .timestamp
45+
46+ @property
47+ def flags (self ):
48+ return self .ptr .flags
49+
50+ @property
51+ def is_keyframe (self ):
52+ return bool (self .ptr .flags & lib .AVINDEX_KEYFRAME )
53+
54+ @property
55+ def is_discard (self ):
56+ return bool (self .ptr .flags & lib .AVINDEX_DISCARD_FRAME )
57+
58+ @property
59+ def size (self ):
60+ return self .ptr .size
61+
62+ @property
63+ def min_distance (self ):
64+ return self .ptr .min_distance
65+
66+
967@cython .cfunc
1068def wrap_index_entries (ptr : cython .pointer [lib .AVStream ]) -> IndexEntries :
1169 obj : IndexEntries = IndexEntries (_cinit_bypass_sentinel )
Original file line number Diff line number Diff line change 11from typing import Iterator , overload
22
3- from av .indexentry import IndexEntry
3+ class IndexEntry :
4+ pos : int
5+ timestamp : int
6+ flags : int
7+ is_keyframe : bool
8+ is_discard : bool
9+ size : int
10+ min_distance : int
411
512class IndexEntries :
613 def __len__ (self ) -> int : ...
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ cimport libav as lib
33from av.codec.context cimport CodecContext
44from av.container.core cimport Container
55from av.frame cimport Frame
6- from av.indexentries cimport IndexEntries
6+ from av.index cimport IndexEntries
77from av.packet cimport Packet
88
99
Original file line number Diff line number Diff line change 33import cython
44from cython .cimports import libav as lib
55from cython .cimports .av .error import err_check
6- from cython .cimports .av .indexentries import wrap_index_entries
6+ from cython .cimports .av .index import wrap_index_entries
77from cython .cimports .av .packet import Packet
88from cython .cimports .av .utils import (
99 avdict_to_dict ,
You can’t perform that action at this time.
0 commit comments