summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
56a17e6)
This is a preparation work for an upcoming multi-threaded decoding.
use nihav_core::codecs::*;
use nihav_core::io::bitreader::*;
use nihav_core::codecs::*;
use nihav_core::io::bitreader::*;
height: usize,
num_mbs: usize,
nal_len: u8,
height: usize,
num_mbs: usize,
nal_len: u8,
- sps: Vec<SeqParameterSet>,
+ sps: Vec<Arc<SeqParameterSet>>,
- pps: Vec<PicParameterSet>,
+ pps: Vec<Arc<PicParameterSet>>,
cur_pps: usize,
skip_mode: FrameSkipMode,
cur_pps: usize,
skip_mode: FrameSkipMode,
let mut br = BitReader::new(&src[..(full_size + 7)/8], BitReaderMode::BE);
br.skip(8)?;
let mut br = BitReader::new(&src[..(full_size + 7)/8], BitReaderMode::BE);
br.skip(8)?;
- let slice_hdr = parse_slice_header(&mut br, &self.sps, &self.pps, is_idr, nal_ref_idc)?;
+ let slice_hdr = parse_slice_header(&mut br, self.sps.as_slice(), self.pps.as_slice(), is_idr, nal_ref_idc)?;
validate!(br.tell() < full_size);
let full_id;
if slice_hdr.first_mb_in_slice == 0 {
validate!(br.tell() < full_size);
let full_id;
if slice_hdr.first_mb_in_slice == 0 {
cur_mb: 0,
is_ref: nal_ref_idc != 0,
long_term: get_long_term_id(is_idr, &slice_hdr),
cur_mb: 0,
is_ref: nal_ref_idc != 0,
long_term: get_long_term_id(is_idr, &slice_hdr),
- mv_info: FrameMV::new(sps.pic_width_in_mbs, sps.pic_height_in_mbs),
+ mv_info: NABufferRef::new(FrameMV::new(sps.pic_width_in_mbs, sps.pic_height_in_mbs)),
6 => {}, //SEI
7 => {
let sps = parse_sps(&src[1..])?;
6 => {}, //SEI
7 => {
let sps = parse_sps(&src[1..])?;
+ self.sps.push(Arc::new(sps));
},
8 => {
validate!(full_size >= 8 + 16);
},
8 => {
validate!(full_size >= 8 + 16);
let mut found = false;
for stored_pps in self.pps.iter_mut() {
if stored_pps.pic_parameter_set_id == pps.pic_parameter_set_id {
let mut found = false;
for stored_pps in self.pps.iter_mut() {
if stored_pps.pic_parameter_set_id == pps.pic_parameter_set_id {
- *stored_pps = pps.clone();
+ *stored_pps = Arc::clone(&pps);
use nihav_core::codecs::DecoderResult;
use nihav_core::frame::{FrameType, NAVideoBufferRef};
use nihav_core::codecs::DecoderResult;
use nihav_core::frame::{FrameType, NAVideoBufferRef};
+use nihav_core::refs::*;
use nihav_codec_support::codecs::MV;
use super::sets::SeqParameterSet;
use super::slice::*;
use nihav_codec_support::codecs::MV;
use super::sets::SeqParameterSet;
use super::slice::*;
pub is_ref: bool,
pub long_term: Option<usize>,
pub is_ref: bool,
pub long_term: Option<usize>,
- pub mv_info: FrameMV, //todo replace with refcounted index to a pool
+ pub mv_info: NABufferRef<FrameMV>,
}
#[derive(Clone,Copy,Default, Debug)]
}
#[derive(Clone,Copy,Default, Debug)]
use nihav_core::codecs::{DecoderResult, DecoderError};
use nihav_core::io::bitreader::*;
use nihav_core::codecs::{DecoderResult, DecoderError};
use nihav_core::io::bitreader::*;
pub second_chroma_qp_index_offset: i8,
}
pub second_chroma_qp_index_offset: i8,
}
-pub fn parse_pps(src: &[u8], sps_arr: &[SeqParameterSet], full_size: usize) -> DecoderResult<PicParameterSet> {
+pub fn parse_pps(src: &[u8], sps_arr: &[Arc<SeqParameterSet>], full_size: usize) -> DecoderResult<Arc<PicParameterSet>> {
let mut br = BitReader::new(src, BitReaderMode::BE);
let mut pps: PicParameterSet = unsafe { std::mem::zeroed() };
let mut br = BitReader::new(src, BitReaderMode::BE);
let mut pps: PicParameterSet = unsafe { std::mem::zeroed() };
pps.second_chroma_qp_index_offset = pps.chroma_qp_index_offset;
}
pps.second_chroma_qp_index_offset = pps.chroma_qp_index_offset;
}
use nihav_core::codecs::{DecoderResult, DecoderError};
use nihav_core::frame::FrameType;
use nihav_core::io::bitreader::*;
use nihav_core::codecs::{DecoderResult, DecoderError};
use nihav_core::frame::FrameType;
use nihav_core::io::bitreader::*;
#[allow(clippy::cognitive_complexity)]
#[allow(clippy::manual_range_contains)]
#[allow(clippy::cognitive_complexity)]
#[allow(clippy::manual_range_contains)]
-pub fn parse_slice_header(br: &mut BitReader, sps_arr: &[SeqParameterSet], pps_arr: &[PicParameterSet], is_idr: bool, nal_ref_idc: u8) -> DecoderResult<SliceHeader> {
+pub fn parse_slice_header(br: &mut BitReader, sps_arr: &[Arc<SeqParameterSet>], pps_arr: &[Arc<PicParameterSet>], is_idr: bool, nal_ref_idc: u8) -> DecoderResult<SliceHeader> {
let mut hdr: SliceHeader = unsafe { std::mem::zeroed() };
hdr.first_mb_in_slice = br.read_ue()? as usize;
let mut hdr: SliceHeader = unsafe { std::mem::zeroed() };
hdr.first_mb_in_slice = br.read_ue()? as usize;