Skip to content

Commit e46221a

Browse files
committed
if _ArraySize_ has a single length, treat as a row vector
1 parent f2bfb65 commit e46221a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

jdatadecode.m

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,19 @@
110110
for j=1:len
111111
if(isfield(data,N_('_ArrayZipSize_')) && isfield(data,N_('_ArrayZipData_')))
112112
zipmethod='zip';
113+
dims=data(j).(N_('_ArrayZipSize_'))(:)';
114+
if(length(dims)==1)
115+
dims=[1 dims];
116+
end
113117
if(isfield(data,N_('_ArrayZipType_')))
114118
zipmethod=data(j).(N_('_ArrayZipType_'));
115119
end
116120
if(~isempty(strmatch(zipmethod,{'zlib','gzip','lzma','lzip','lz4','lz4hc'})))
117121
decompfun=str2func([zipmethod 'decode']);
118122
if(needbase64)
119-
ndata=reshape(typecast(decompfun(base64decode(data(j).(N_('_ArrayZipData_')))),data(j).(N_('_ArrayType_'))),data(j).(N_('_ArrayZipSize_'))(:)');
123+
ndata=reshape(typecast(decompfun(base64decode(data(j).(N_('_ArrayZipData_')))),data(j).(N_('_ArrayType_'))),dims);
120124
else
121-
ndata=reshape(typecast(decompfun(data(j).(N_('_ArrayZipData_'))),data(j).(N_('_ArrayType_'))),data(j).(N_('_ArrayZipSize_'))(:)');
125+
ndata=reshape(typecast(decompfun(data(j).(N_('_ArrayZipData_'))),data(j).(N_('_ArrayType_'))),dims);
122126
end
123127
else
124128
error('compression method is not supported');
@@ -130,7 +134,11 @@
130134
ndata=cast(data(j).(N_('_ArrayData_')),char(data(j).(N_('_ArrayType_'))));
131135
end
132136
if(isfield(data,N_('_ArrayZipSize_')))
133-
ndata=reshape(ndata(:),fliplr(data(j).(N_('_ArrayZipSize_'))(:)'));
137+
dims=data(j).(N_('_ArrayZipSize_'))(:)';
138+
if(length(dims)==1)
139+
dims=[1 dims];
140+
end
141+
ndata=reshape(ndata(:),fliplr(dims));
134142
ndata=permute(ndata,ndims(ndata):-1:1);
135143
end
136144
iscpx=0;
@@ -142,6 +150,9 @@
142150
if(isfield(data,N_('_ArrayIsSparse_')) && data(j).(N_('_ArrayIsSparse_')))
143151
if(isfield(data,N_('_ArraySize_')))
144152
dim=double(data(j).(N_('_ArraySize_'))(:)');
153+
if(length(dim)==1)
154+
dim=[1 dim];
155+
end
145156
if(iscpx)
146157
ndata(end-1,:)=complex(ndata(end-1,:),ndata(end,:));
147158
end
@@ -172,6 +183,9 @@
172183
data(j).(N_('_ArraySize_'))=data(j).(N_('_ArraySize_'))(end:-1:1);
173184
end
174185
dims=data(j).(N_('_ArraySize_'))(:)';
186+
if(length(dims)==1)
187+
dims=[1 dims];
188+
end
175189
ndata=reshape(ndata(:),dims(:)');
176190
if(format>1.9)
177191
ndata=permute(ndata,ndims(ndata):-1:1);

0 commit comments

Comments
 (0)