aboutsummaryrefslogtreecommitdiffstats
path: root/nihav-commonfmt
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2023-06-17 11:03:04 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2023-06-17 11:03:04 +0200
commit04fafc56d5f430ae289eaeabec24e2831e92d191 (patch)
tree442f08c10b33ba8801c3a909a210ece25560a2c0 /nihav-commonfmt
parent99ddf2c50981ad72bc853f01be9939f3ff3d1dad (diff)
downloadnihav-04fafc56d5f430ae289eaeabec24e2831e92d191.tar.gz
avimux: set palette change flag in stream header if applicable
Diffstat (limited to 'nihav-commonfmt')
-rw-r--r--nihav-commonfmt/src/muxers/avi.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/nihav-commonfmt/src/muxers/avi.rs b/nihav-commonfmt/src/muxers/avi.rs
index 02283e4..d8e1f73 100644
--- a/nihav-commonfmt/src/muxers/avi.rs
+++ b/nihav-commonfmt/src/muxers/avi.rs
@@ -16,6 +16,7 @@ struct AVIStream {
nframes: u32,
is_video: bool,
max_size: u32,
+ pal_change: bool,
}
struct AVIMuxer<'a> {
@@ -144,6 +145,7 @@ impl<'a> MuxCore<'a> for AVIMuxer<'a> {
is_video: strm.get_media_type() == StreamType::Video,
nframes: 0,
max_size: 0,
+ pal_change: false,
});
self.bw.write_u32le(0)?; // flags
@@ -283,6 +285,7 @@ impl<'a> MuxCore<'a> for AVIMuxer<'a> {
self.bw.write_byte((end_clr - start_clr) as u8)?;
self.bw.write_u16le(0)?; //flags
self.bw.write_buf(&pal[start_clr * 4..end_clr * 4])?;
+ self.stream_info[str_num].pal_change = true;
}
}
}
@@ -325,6 +328,10 @@ impl<'a> MuxCore<'a> for AVIMuxer<'a> {
for stri in self.stream_info.iter() {
max_frames = max_frames.max(stri.nframes);
max_size = max_size.max(stri.max_size);
+ if stri.pal_change {
+ self.bw.seek(SeekFrom::Start(stri.strh_pos))?;
+ self.bw.write_u32le(0x00010000)?;
+ }
self.bw.seek(SeekFrom::Start(stri.strh_pos + 0x18))?;
self.bw.write_u32le(if stri.is_video { stri.nframes } else { 0 })?;
self.bw.write_u32le(stri.max_size)?;