X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-commonfmt%2Fsrc%2Fcodecs%2Fcinepakenc.rs;h=882b63701ffa42a29b34f55ad2e6955c02b15a80;hb=1047e98335ad782b48bcc88e9277336576c20597;hp=645bd834d1496e2ea26e0f066a49a5d6fd01a545;hpb=3c406629cabc3b77f9198646b0f93fc7e486e277;p=nihav.git diff --git a/nihav-commonfmt/src/codecs/cinepakenc.rs b/nihav-commonfmt/src/codecs/cinepakenc.rs index 645bd83..882b637 100644 --- a/nihav-commonfmt/src/codecs/cinepakenc.rs +++ b/nihav-commonfmt/src/codecs/cinepakenc.rs @@ -707,10 +707,10 @@ impl CinepakEncoder { self.render_stripe(true, start_line, end_line); - if self.v1_idx.len() == 0 { + if self.v4_idx.len() == 0 { bw.write_byte(0x32)?; - bw.write_u24be((self.v4_idx.len() + 4) as u32)?; - bw.write_buf(self.v4_idx.as_slice())?; + bw.write_u24be((self.v1_idx.len() + 4) as u32)?; + bw.write_buf(self.v1_idx.as_slice())?; } else { bw.write_byte(0x30)?; bw.write_u24be(0)?; @@ -929,7 +929,9 @@ impl NAEncoder for CinepakEncoder { let out_info = NAVideoInfo::new(vinfo.width, vinfo.height, false, vinfo.format); let info = NACodecInfo::new("cinepak", NACodecTypeInfo::Video(out_info.clone()), None); - let stream = NAStream::new(StreamType::Video, stream_id, info, encinfo.tb_num, encinfo.tb_den).into_ref(); + let mut stream = NAStream::new(StreamType::Video, stream_id, info, encinfo.tb_num, encinfo.tb_den); + stream.set_num(stream_id as usize); + let stream = stream.into_ref(); self.stream = Some(stream.clone()); self.quality = encinfo.quality; @@ -943,7 +945,7 @@ impl NAEncoder for CinepakEncoder { let buf = alloc_video_buffer(out_info, 2)?; self.lastfrm = Some(buf.get_vbuf().unwrap()); - + Ok(stream) }, } @@ -982,7 +984,7 @@ impl NAEncoder for CinepakEncoder { const ENCODER_OPTS: &[NAOptionDefinition] = &[ NAOptionDefinition { - name: "key_int", description: "Keyframe interval (0 - automatic)", + name: KEYFRAME_OPTION, description: KEYFRAME_OPTION_DESC, opt_type: NAOptionDefinitionType::Int(Some(0), Some(128)) }, NAOptionDefinition { name: "nstrips", description: "Number of strips per frame (0 - automatic)", @@ -996,11 +998,10 @@ impl NAOptionHandler for CinepakEncoder { fn get_supported_options(&self) -> &[NAOptionDefinition] { ENCODER_OPTS } fn set_options(&mut self, options: &[NAOption]) { for option in options.iter() { -println!("option {}", option.name); for opt_def in ENCODER_OPTS.iter() { if opt_def.check(option).is_ok() { match option.name { - "key_int" => { + KEYFRAME_OPTION => { if let NAValue::Int(intval) = option.value { self.key_int = intval as u8; } @@ -1028,7 +1029,7 @@ println!("option {}", option.name); } fn query_option_value(&self, name: &str) -> Option { match name { - "key_int" => Some(NAValue::Int(i64::from(self.key_int))), + KEYFRAME_OPTION => Some(NAValue::Int(i64::from(self.key_int))), "nstrips" => Some(NAValue::Int(self.nstrips as i64)), "quant_mode" => Some(NAValue::String(self.qmode.to_string())), _ => None,