Place the frame_config's pos before it not after

This commit is contained in:
Nigel Tao committed 2018-08-26 23:58:03 +10:00
1 parent 9c04249bfe
commit a34cc5311e
7 files changed
+73 -176

No files matched your search

+15 -34
View File
@@ -92,6 +92,7 @@ pub struct decoder?(
// There are 7056000 flicks per centisecond.
gc_duration base.u64[..0xFFFF * 7056000],
frame_config_io_position base.u64,
num_decoded_frame_configs_value base.u64,
num_decoded_frames_value base.u64,
@@ -165,29 +166,15 @@ pub func decoder.work_buffer_size() base.range_ii_u64 {
return this.util.make_range_ii_u64(min_incl:0, max_incl:0)
}
pub func decoder.reset_for_decode_frame!??(fc ptr base.frame_config) {
pub func decoder.reset_before!??(fc ptr base.frame_config) {
if this.call_sequence == 0 {
return status "?bad call sequence"
}
// TODO: change ~sat+ to + or change the semantics so that the io_position
// is before, not after, the frame config.
this.num_decoded_frame_configs_value = args.fc.index() ~sat+ 1
this.num_decoded_frames_value = args.fc.index()
this.frame_rect_x0 = args.fc.rect_x0()
this.frame_rect_y0 = args.fc.rect_y0()
this.frame_rect_x1 = args.fc.rect_x1()
this.frame_rect_y1 = args.fc.rect_y1()
this.dst_x = this.frame_rect_x0
this.dst_y = this.frame_rect_y0
// TODO: take an io_reader and check that its pos equals fc's pos?
this.end_of_data = false
// TODO: delete this hack.
this.call_sequence = 2
// TODO: restoring the state above isn't enough. We also need to restore
// gc_etc fields like gc_transparent_index, but they're not in args.fc.
this.num_decoded_frame_configs_value = args.fc.index()
this.num_decoded_frames_value = this.num_decoded_frame_configs_value
this.reset_gc!()
}
pub func decoder.decode_frame_config!??(dst nptr base.frame_config, src base.io_reader) {
@@ -221,7 +208,7 @@ pub func decoder.decode_frame_config!??(dst nptr base.frame_config, src base.io_
max_excl_y:this.frame_rect_y1),
duration:this.gc_duration,
index:this.num_decoded_frame_configs_value,
io_position:args.src.position(),
io_position:this.frame_config_io_position,
blend:blend,
disposal:this.gc_disposal)
}
@@ -236,20 +223,11 @@ pri func decoder.skip_frame!??(src base.io_reader) {
if (flags & 0x80) != 0 {
args.src.skip!??(n:(3 as base.u32) << (1 + (flags & 0x07)))
}
var lw base.u8 = args.src.read_u8!??()
this.skip_blocks!??(src:args.src)
// The Image Descriptor is mandatory, but the Graphic Control extension is
// optional. Reset the GC related fields for the next decode_frame call.
this.seen_graphic_control = false
this.gc_has_transparent_index = false
this.gc_transparent_index = 0
this.gc_disposal = 0
this.gc_duration = 0
this.num_decoded_frames_value ~sat+= 1
this.call_sequence = 3
this.reset_gc!()
}
// TODO: honor pixbuf_origin_x and pixbuf_origin_y args.
@@ -257,9 +235,14 @@ pub func decoder.decode_frame!??(dst ptr base.pixel_buffer, pixbuf_origin_x base
if this.call_sequence != 2 {
this.decode_frame_config!??(dst:nullptr, src:args.src)
}
this.decode_id_part1!??(dst:args.dst, src:args.src)
this.num_decoded_frames_value ~sat+= 1
this.reset_gc!()
}
pri func decoder.reset_gc!() {
this.call_sequence = 3
// The Image Descriptor is mandatory, but the Graphic Control extension is
// optional. Reset the GC related fields for the next decode_frame call.
this.seen_graphic_control = false
@@ -267,12 +250,10 @@ pub func decoder.decode_frame!??(dst ptr base.pixel_buffer, pixbuf_origin_x base
this.gc_transparent_index = 0
this.gc_disposal = 0
this.gc_duration = 0
this.num_decoded_frames_value ~sat+= 1
this.call_sequence = 3
}
pri func decoder.decode_up_to_id_part1!??(src base.io_reader) {
this.frame_config_io_position = args.src.position()
while true {
var block_type base.u8 = args.src.read_u8!??()
if block_type == 0x21 { // The spec calls 0x21 the "Extension Introducer".