pub struct Decoder<T>where
T: DecodedHandle + DynDecodedHandle,{Show 24 fields
parser: Parser,
blocking_mode: BlockingMode,
backend: Box<dyn StatelessDecoderBackend<Handle = T>>,
negotiation_status: NegotiationStatus,
coded_resolution: Resolution,
ready_queue: BinaryHeap<ReadyPicture<T>>,
current_display_order: u64,
dpb: Dpb<T>,
max_num_reorder_frames: u32,
cur_sps_id: u8,
cur_pps_id: u8,
prev_ref_pic_info: PrevReferencePicInfo,
prev_pic_info: PrevPicInfo,
curr_info: CurrentPicInfo,
cur_pic: Option<PictureData>,
last_field: Option<(Rc<RefCell<PictureData>>, T)>,
ref_pic_list_p0: Vec<DpbEntry<T>>,
ref_pic_list_b0: Vec<DpbEntry<T>>,
ref_pic_list_b1: Vec<DpbEntry<T>>,
ref_frame_list_0_short_term: Vec<DpbEntry<T>>,
ref_frame_list_1_short_term: Vec<DpbEntry<T>>,
ref_frame_list_long_term: Vec<DpbEntry<T>>,
ref_pic_list0: Vec<DpbEntry<T>>,
ref_pic_list1: Vec<DpbEntry<T>>,
}
Fields
parser: Parser
A parser to extract bitstream metadata
blocking_mode: BlockingMode
Whether the decoder should block on decode operations.
backend: Box<dyn StatelessDecoderBackend<Handle = T>>
The backend used for hardware acceleration.
negotiation_status: NegotiationStatus
Keeps track of whether the decoded format has been negotiated with the backend.
coded_resolution: Resolution
The current coded resolution
ready_queue: BinaryHeap<ReadyPicture<T>>
A queue with the handles of pictures that are ready to be sent to the DecoderSession, with the lowest order at the top.
current_display_order: u64
A monotonically increasing counter used to tag pictures in display order
dpb: Dpb<T>
The decoded picture buffer
max_num_reorder_frames: u32
Indicates an upper bound for the number of frames buffers, in the decoded picture buffer (DPB), that are required for storing frames, complementary field pairs, and non-paired fields before output. It is a requirement of bitstream conformance that the maximum number of frames, complementary field pairs, or non-paired fields that precede any frame, complementary field pair, or non-paired field in the coded video sequence in decoding order and follow it in output order shall be less than or equal to max_num_reorder_frames.
cur_sps_id: u8
The current active SPS id.
cur_pps_id: u8
The current active PPS id.
prev_ref_pic_info: PrevReferencePicInfo
Cached variables from the previous reference picture.
prev_pic_info: PrevPicInfo
Cached variables from the previous picture.
curr_info: CurrentPicInfo
Cached variables from the current picture.
cur_pic: Option<PictureData>
The current picture being worked on.
last_field: Option<(Rc<RefCell<PictureData>>, T)>
A cached, non-reference first field that did not make it into the DPB because it was full even after bumping the smaller POC. This field will be cached until the second field is processed so they can be output together.
We are not using DbpEntry<T>
as the type because contrary to a DPB entry,
the handle of this member is always valid.
ref_pic_list_p0: Vec<DpbEntry<T>>
Reference picture list for P slices. Retains the same meaning as in the specification. Points into the pictures stored in the DPB. Derived once per picture.
ref_pic_list_b0: Vec<DpbEntry<T>>
Reference picture list 0 for B slices. Retains the same meaning as in the specification. Points into the pictures stored in the DPB. Derived once per picture.
ref_pic_list_b1: Vec<DpbEntry<T>>
Reference picture list 1 for B slices. Retains the same meaning as in the specification. Points into the pictures stored in the DPB. Derived once per picture.
ref_frame_list_0_short_term: Vec<DpbEntry<T>>
Equivalent to refFrameList0ShortTerm in the spec. Used for building the references for P, SP and B slices in fields (8.2.4.2.2, 8.2.4.2.4). Derived once per field.
ref_frame_list_1_short_term: Vec<DpbEntry<T>>
Equivalent to refFrameList1ShortTerm in the spec. Used for building the references for B slices in fields (8.2.4.2.4). Derived once per field.
ref_frame_list_long_term: Vec<DpbEntry<T>>
Equivalent to refFrameList0LongTerm in the spec. Used for building the references for P, SP and B slices in fields (8.2.4.2.2, 8.2.4.2.4). Derived once per field.
ref_pic_list0: Vec<DpbEntry<T>>
Equivalent to RefPicList0 in the specification. Computed for every slice, points to the pictures in the DPB.
ref_pic_list1: Vec<DpbEntry<T>>
Equivalent to RefPicList1 in the specification. Computed for every slice, points to the pictures in the DPB.
Implementations
sourceimpl Decoder<VADecodedHandle>
impl Decoder<VADecodedHandle>
pub fn new_vaapi(
display: Rc<Display>,
blocking_mode: BlockingMode
) -> Result<Self>
sourceimpl<T> Decoder<T>where
T: DecodedHandle + DynDecodedHandle + 'static,
impl<T> Decoder<T>where
T: DecodedHandle + DynDecodedHandle + 'static,
pub(crate) fn new(
backend: Box<dyn StatelessDecoderBackend<Handle = T>>,
blocking_mode: BlockingMode
) -> Result<Self>
fn negotiation_possible(
sps: &Sps,
dpb: &Dpb<T>,
current_resolution: Resolution
) -> Result<bool>
fn get_max_num_order_frames(sps: &Sps, max_dpb_frames: usize) -> u32
fn process_sps(&mut self, nalu: &Nalu<impl AsRef<[u8]>>) -> Result<()>
fn compute_pic_order_count(&mut self, pic: &mut PictureData) -> Result<()>
fn update_pic_nums(
&mut self,
frame_num: i32,
gap_picture: Option<&PictureData>
) -> Result<()>
fn sort_pic_num_descending(pics: &mut [DpbEntry<T>])
fn sort_long_term_pic_num_ascending(pics: &mut [DpbEntry<T>])
fn sort_frame_num_wrap_descending(pics: &mut [DpbEntry<T>])
fn sort_long_term_frame_idx_ascending(pics: &mut [DpbEntry<T>])
fn debug_ref_list_p(ref_pic_list: &[DpbEntry<T>], field_pic: bool)
fn debug_ref_list_b(ref_pic_list: &[DpbEntry<T>], ref_pic_list_name: &str)
sourcefn init_ref_pic_list_p(&mut self)
fn init_ref_pic_list_p(&mut self)
8.2.4.2.1 Initialization process for the reference picture list for P and SP slices in frames
sourcefn init_ref_field_pic_list_p(&mut self)
fn init_ref_field_pic_list_p(&mut self)
8.2.4.2.2 Initialization process for the reference picture list for P and SP slices in fields
fn sort_poc_descending(pics: &mut [DpbEntry<T>])
fn sort_poc_ascending(pics: &mut [DpbEntry<T>])
fn swap_b1_if_needed(&mut self)
fn init_ref_pic_list_b(&mut self)
sourcefn init_ref_field_pic_list_b(&mut self)
fn init_ref_field_pic_list_b(&mut self)
8.2.4.2.4 Initialization process for reference picture lists for B slices in fields
sourcefn init_ref_field_pic_list(
&mut self,
ref_frame_list_name: RefFrameListName,
ref_pic_list_name: RefPicListName
)
fn init_ref_field_pic_list(
&mut self,
ref_frame_list_name: RefFrameListName,
ref_pic_list_name: RefPicListName
)
Copies from refFrameListXShortTerm and refFrameListLongTerm into RefPicListX as per 8.2.4.2.5. Used when building the reference list for fields in interlaced decoding.
fn init_ref_pic_lists(&mut self)
fn sliding_window_marking(&mut self, pic: &mut PictureData) -> Result<()>
fn mmco_op_1(&self, pic: &PictureData, marking: usize) -> Result<()>
fn mmco_op_2(&self, pic: &PictureData, marking: usize) -> Result<()>
fn mmco_op_3(&self, pic: &PictureData, marking: usize) -> Result<()>
fn mmco_op_4(&mut self, pic: &PictureData, marking: usize) -> Result<()>
fn mmco_op_5(&mut self, pic: &mut PictureData) -> Result<()>
fn mmco_op_6(&mut self, pic: &mut PictureData, marking: usize) -> Result<()>
fn handle_memory_management_ops(&mut self, pic: &mut PictureData) -> Result<()>
sourcefn fill_prev_ref_info(&mut self, pic: &PictureData)
fn fill_prev_ref_info(&mut self, pic: &PictureData)
Store some variables related to the previous reference picture. These will be used in the decoding of future pictures.
sourcefn fill_prev_info(&mut self, pic: &PictureData)
fn fill_prev_info(&mut self, pic: &PictureData)
Store some variables related to the previous picture. These will be used in the decoding of future pictures.
fn reference_pic_marking(&mut self, pic: &mut PictureData) -> Result<()>
fn add_to_dpb(
&mut self,
pic: Rc<RefCell<PictureData>>,
handle: Option<T>
) -> Result<()>
sourcefn add_to_ready_queue(&mut self, pic_rc: Rc<RefCell<PictureData>>, handle: T)
fn add_to_ready_queue(&mut self, pic_rc: Rc<RefCell<PictureData>>, handle: T)
Adds picture to the ready queue if it could not be added to the DPB.
fn finish_picture(&mut self, pic: PictureData, handle: T) -> Result<()>
fn handle_frame_num_gap(&mut self, frame_num: i32, timestamp: u64) -> Result<()>
sourcefn init_current_pic(
&mut self,
slice: &Slice<&[u8]>,
first_field: Option<Rc<RefCell<PictureData>>>,
timestamp: u64
) -> Result<()>
fn init_current_pic(
&mut self,
slice: &Slice<&[u8]>,
first_field: Option<Rc<RefCell<PictureData>>>,
timestamp: u64
) -> Result<()>
Init the current picture being decoded.
sourcefn bump_as_needed(&mut self, current_pic: &PictureData) -> Vec<DpbEntry<T>>
fn bump_as_needed(&mut self, current_pic: &PictureData) -> Vec<DpbEntry<T>>
Bumps the DPB if needed. DPB bumping is described on C.4.5.3.
fn clear_ref_pic_lists(&mut self)
sourcefn get_ready_frames(&mut self) -> Vec<T>
fn get_ready_frames(&mut self) -> Vec<T>
Get the DecodedFrameHandles for the pictures in the ready queue, in display order.
sourcefn find_first_field(
&mut self,
slice: &Slice<impl AsRef<[u8]>>
) -> Result<Option<(Rc<RefCell<PictureData>>, T)>>
fn find_first_field(
&mut self,
slice: &Slice<impl AsRef<[u8]>>
) -> Result<Option<(Rc<RefCell<PictureData>>, T)>>
Find the first field for the picture started by slice
, if any.
sourcefn handle_picture(&mut self, timestamp: u64, slice: &Slice<&[u8]>) -> Result<()>
fn handle_picture(&mut self, timestamp: u64, slice: &Slice<&[u8]>) -> Result<()>
Handle a picture. Called only once. Uses an heuristic to determine when a new picture starts in the slice NALUs.
fn pic_num_f(pic: &PictureData, max_pic_num: i32) -> i32
fn long_term_pic_num_f(pic: &PictureData, max_long_term_frame_idx: i32) -> i32
fn copy_into_ref_pic_list(
&mut self,
ref_pic_list: RefPicList,
ref_pic_list_name: RefPicListName
)
fn short_term_pic_list_modification(
&mut self,
current_slice: &Slice<impl AsRef<[u8]>>,
ref_pic_list: RefPicList,
rplm: &RefPicListModification,
pic_num_lx_pred: &mut i32,
ref_idx_lx: &mut usize
) -> Result<()>
fn long_term_pic_list_modification(
&mut self,
current_slice: &Slice<impl AsRef<[u8]>>,
ref_pic_list: RefPicList,
rplm: &RefPicListModification,
ref_idx_lx: &mut usize
) -> Result<()>
fn modify_ref_pic_list(
&mut self,
current_slice: &Slice<impl AsRef<[u8]>>,
ref_pic_list: RefPicList
) -> Result<()>
fn modify_ref_pic_lists(
&mut self,
current_slice: &Slice<impl AsRef<[u8]>>
) -> Result<()>
sourcefn handle_slice(&mut self, timestamp: u64, slice: &Slice<&[u8]>) -> Result<()>
fn handle_slice(&mut self, timestamp: u64, slice: &Slice<&[u8]>) -> Result<()>
Handle a slice. Called once per slice NALU.
sourcefn submit_picture(&mut self) -> VideoDecoderResult<(PictureData, T)>
fn submit_picture(&mut self) -> VideoDecoderResult<(PictureData, T)>
Submits the picture to the accelerator.
pub fn get_raster_from_zigzag_8x8(src: [u8; 64], dst: &mut [u8; 64])
pub fn get_raster_from_zigzag_4x4(src: [u8; 16], dst: &mut [u8; 16])
fn peek_sps(parser: &mut Parser, bitstream: &[u8]) -> Option<Sps>
fn decode_access_unit(
&mut self,
timestamp: u64,
bitstream: &[u8]
) -> VideoDecoderResult<()>
fn block_on_one(&mut self) -> VideoDecoderResult<()>
Trait Implementations
sourceimpl<T> VideoDecoder for Decoder<T>where
T: DecodedHandle + DynDecodedHandle + 'static,
impl<T> VideoDecoder for Decoder<T>where
T: DecodedHandle + DynDecodedHandle + 'static,
sourcefn decode(
&mut self,
timestamp: u64,
bitstream: &[u8]
) -> VideoDecoderResult<Vec<Box<dyn DynDecodedHandle>>>
fn decode(
&mut self,
timestamp: u64,
bitstream: &[u8]
) -> VideoDecoderResult<Vec<Box<dyn DynDecodedHandle>>>
bitstream
represented by timestamp
. Returns zero or more
decoded handles representing the decoded data. Read moresourcefn flush(&mut self) -> VideoDecoderResult<Vec<Box<dyn DynDecodedHandle>>>
fn flush(&mut self) -> VideoDecoderResult<Vec<Box<dyn DynDecodedHandle>>>
sourcefn negotiation_possible(&self) -> bool
fn negotiation_possible(&self) -> bool
decode()
method. Read more