No BSD License  

Highlights from
Scalable MPEG compression based on DCT coefficients

Scalable MPEG compression based on DCT coefficients

by

 

15 Nov 2006 (Updated )

This application makes 2 layers base Layer and enhancement layer from quantized coefficients

[valq,runq]=rle(result)
function [valq,runq]=rle(result)
counter=0;
s=size(result);
%flag=0;
j=1;
%i=1;

%while i<=s(2)
for i=1:s(2)    
    if result(i)~=0
        val(j)=result(i);
        run(j)=counter;
        %i=i+1;
        j=j+1;
        counter=0;
    elseif result(i)==0
        counter=counter+1;
        %i=i+1;
        if counter==15 
            %i=i-1;
            val(j)=result(i);
            run(j)=counter;
            %i=i+1;
            j=j+1;
            counter=0;
        end
%         if i==s(2)
%             val(j)=result(i);
%             run(j)=counter;
%             %i=i+1;
%             j=j+1;
%             counter=0;
%         end
    end
 %   i=i+1;
end
%check if last value has run of zero

j=j-1;
temp_index = 0;
for i=j:-1:1
    if i == 1
        if val(i) ~=0 
            val(i+1)= 0;
            run(i+1)= 0;
            temp_index = i+1 ;
            break;
        elseif val(i) ==0  
            val(i)= 0;
            run(i)= 0;
            temp_index = i ;
            break;
        end
    elseif val(i) ~=0 
        val(i+1)= 0;
        run(i+1)= 0;
        temp_index = i+1 ;
        break;
    elseif val(i)==0 & run(i) ~= 0
        continue;
    end
end
% if temp_index == 0 
%     tep_index = 1 ;
% end
if temp_index~=0
     valq(1:temp_index)=val(1:temp_index);
     runq(1:temp_index)=run(1:temp_index);
 else
     valq(1)=0;
     runq(1)=0;
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% flag=1;
% while j>0 & val(j)==0 & run(j)~=0
%     val(j)=0;
%     run(j)=0;
%     flag=0;
%     j=j-1;
% end
% 
% if flag~=0
%     val(j)=0;
%     run(j)=0;
% end
% x=size(val);
% i=1;
% flag1=1;
% while flag1~=0
%     valq(i)=val(i);
%     runq(i)=run(i);
%     if valq(i)==0 & runq(i)==0
%         flag1=0;
%     end
%     i=i+1;
% end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% true=0;
% 
%     while true~=1 
%         if (val(j)==0 & run(j)~=0)
%             val(j)=0;
%             run(j)=0;
%             j=j-1;
%             if j==1
%                 if val(j)==0 & run(j)~=0
%                     run(j)=0;
%                     break
%                 end
%             end
%         else
%             val(j+1)=0;
%             run(j+1)=0;
%             true=1;
%         end
%     
%     end
%     sv=size(val);
%     for i=1:sv(2)
%         valq(i)=val(i);
%         runq(i)=run(i);
%         if valq(i)==0 & runq(i)==0
%             break
%         end
%     end
%  val
% i=1;
% while val(i)~=0 & run(i)~=0
%     valq(i)=val(i);
%     runq(i)=run(i);
%     i=i+1;
% end
% valq(i)=0;
% runq(i)=0;

Contact us