% Project 1
% Andy Doran
%
% function [bits,hdcmp] = mask(dcmp)
%
% dcmp = desired pre-gzip compression ratio
%      = 1, .75, .5, .375, .25, .125,  or .0625
% bits = 16x16 matrix containing quantization bit size at each indice
%        for corresponding 16x16 image block
% hdcmp = integer code for compression ratio
%

function [bits,hdcmp] = mask(dcmp)

if (dcmp == 1)
  bits = 8*ones(16,16);
  hdcmp = 1;
end

if (dcmp == .75)
  bits = 8*ones(16,16);
  bits(9:16,9:16) = 0;
  hdcmp = 2;
end

if (dcmp == .5)
  bits = 4*ones(16,16);
  bits(9:16,9:16) = 0;
  bits(1:8,1:8) = 8;
  hdcmp = 3;
end

if (dcmp == .375)
  bits = 2*ones(16,16);
  bits(9:16,9:16) = 0;
  bits(1:8,1:8) = 8;
  hdcmp = 4;
end

if (dcmp == .25)
  bits = 2*ones(16,16);
  bits(9:16,9:16) = 0;
  bits(1:8,1:8) = 3;
  bits(1:4,1:4) = 6;
  bits(1:2,1:2) = 8;
  hdcmp = 5;
end

if (dcmp == .125)
  bits = ones(16,16);
  bits(9:16,9:16) = 0;
  bits(1:8,1:8) = 1;
  bits(1:4,1:4) = 4;
  bits(1:2,1:2) = 8;
  hdcmp = 6;
end

if (dcmp == .0625)
  bits = zeros(16,16);
  bits(9:16,9:16) = 0;
  bits(1:8,1:8) = 1;
  bits(1:4,1:4) = 4;
  bits(1:2,1:2) = 8;
  hdcmp = 7;
end
