1
0
mirror of https://github.com/specht/champ.git synced 2024-06-09 19:29:28 +00:00

fixed code size issue in pgif

This commit is contained in:
Michael Specht 2018-02-14 22:15:52 +01:00
parent 68bfd5dadf
commit a091d74dcd
2 changed files with 7 additions and 8 deletions

View File

@ -149,9 +149,7 @@ class Champ
go = nil
gt = nil
if @record_frames
gi, go, gt = Open3.popen2("./pgif 280 192 4 > #{File.join(@files_dir, 'frames.gif')}")
gi.puts '000000'
gi.puts 'ffffff'
gi, go, gt = Open3.popen2("./pgif 280 192 2 > #{File.join(@files_dir, 'frames.gif')}")
gi.puts '000000'
gi.puts 'ffffff'
end
@ -221,9 +219,6 @@ class Champ
(2...frame_cycles.size).each do |i|
@cycles_per_frame << frame_cycles[i] - frame_cycles[i - 1]
end
if @cycles_per_frame.size > 0
puts "Cycles per frame: #{@cycles_per_frame.inject(0) { |sum, x| sum + x } / @cycles_per_frame.size}"
end
end
end

8
pgif.c
View File

@ -122,6 +122,8 @@ void encode_image(uint8_t* pixels, uint8_t* previous_pixels,
uint8_t color_depth = 1;
while (colors_used > (1 << color_depth))
color_depth++;
if (color_depth < 2)
color_depth = 2;
uint16_t cropped_left = 0;
uint16_t cropped_top = 0;
@ -240,8 +242,8 @@ void encode_image(uint8_t* pixels, uint8_t* previous_pixels,
put_struct(&id, sizeof(id));
uint8_t lzw_minimum_code_size = color_depth;
if (lzw_minimum_code_size < 2)
lzw_minimum_code_size = 2;
// if (lzw_minimum_code_size < 2)
// lzw_minimum_code_size = 2;
put8(lzw_minimum_code_size);
@ -343,6 +345,8 @@ int main(int argc, char** argv)
uint8_t color_depth = 1;
while (colors_used > (1 << color_depth))
color_depth++;
if (color_depth < 2)
color_depth = 2;
// write header
struct header_block header;