diff --git a/decode.m b/decode.m index 23d22eed9ccb5f906e492019dd83ab67cb55c247..b8d7080d64038368d296b4062d747b4ac87467b4 100644 --- a/decode.m +++ b/decode.m @@ -7,25 +7,25 @@ TAppDecoder = fullfile(HEVCDir,'bin','TAppDecoder.exe'); p = inputParser; p.KeepUnmatched = true; p.StructExpand = true; -p.addParameter('BitstreamFile','bit.hevc',@ischar); -p.addParameter('ReconFile' ,'rec.yuv' ,@ischar); -p.addParameter('SkipFrames' ,'0' ,@ischar); +p.addParameter('BitstreamFile' ,'bit.hevc',@ischar); +p.addParameter('ReconFile' ,'rec.yuv' ,@ischar); +p.addParameter('SkipFrames' ,'0' ,@ischar); +p.addParameter('WarnUnknowParameter','1' ,@ischar); %p.addParameter('LogFile' ,'log.rtf' ,@ischar); % Add additional default parameters here p.parse(varargin{:}); -parameters = fieldnames (p.Results); -values = struct2cell(p.Results); - -% extraParameters = fieldnames (p.Unmatched); -% extraValues = struct2cell(p.Unmatched); -% argList = paramToArg([parameters;extraParameters],[values;extraValues]); +results = p.Results; +parameters = fieldnames (results); +values = struct2cell(results); argList = paramToArg(parameters,values); command = [TAppDecoder,' ',argList]; -system(command); +disp(command) +status = system(command); +if status, error('HEVC Error'); end end diff --git a/encode.m b/encode.m index 935710ba9a12b9761c00525c57b8f85cda75ca2a..b63b81f9145c11c5cd5e5cf64faba0c90aaabc65 100644 --- a/encode.m +++ b/encode.m @@ -8,29 +8,37 @@ defaultCfg = fullfile(HEVCDir,'cfg','intra.cfg'); p = inputParser; p.KeepUnmatched = true; p.StructExpand = true; -p.addParameter('ConfigFile' ,defaultCfg,@ischar); -p.addParameter('InputFile' ,'ref.yuv' ,@ischar); -p.addParameter('BitstreamFile' ,'bit.hevc',@ischar); -p.addParameter('ReconFile' ,'rec.yuv' ,@ischar); -p.addParameter('LogFile' ,'log.rtf' ,@ischar); -p.addParameter('SourceWidth' ,'512' ,@ischar); -p.addParameter('SourceHeight' ,'512' ,@ischar); -p.addParameter('InputBitDepth' ,'8' ,@ischar); -p.addParameter('InternalBitDepth' ,'8' ,@ischar); -p.addParameter('InputChromaFormat','420' ,@ischar); -p.addParameter('FrameRate' ,'60' ,@ischar); -p.addParameter('FrameSkip' ,'0' ,@ischar); -p.addParameter('FramesToBeEncoded','1' ,@ischar); -p.addParameter('QP' ,'30' ,@ischar); +p.addParameter('ConfigFile' ,defaultCfg,@ischar); +p.addParameter('InputFile' ,'ref.yuv' ,@ischar); +p.addParameter('BitstreamFile' ,'bit.hevc',@ischar); +p.addParameter('ReconFile' ,'rec.yuv' ,@ischar); +p.addParameter('LogFile' ,'log.rtf' ,@ischar); +p.addParameter('SourceWidth' ,'512' ,@ischar); +p.addParameter('SourceHeight' ,'512' ,@ischar); +p.addParameter('InputBitDepth' ,'8' ,@ischar); +p.addParameter('InternalBitDepth' ,'8' ,@ischar); +p.addParameter('InputChromaFormat' ,'420' ,@ischar); +p.addParameter('FrameRate' ,'60' ,@ischar); +p.addParameter('FrameSkip' ,'0' ,@ischar); +p.addParameter('FramesToBeEncoded' ,'1' ,@ischar); +p.addParameter('QP' ,'30' ,@ischar); +p.addParameter('WarnUnknowParameter','1' ,@ischar); % Add additional default parameters here p.parse(varargin{:}); -parameters = fieldnames (p.Results); -values = struct2cell(p.Results); +perm = 1:numel(p.Parameters); +indconf = find(strcmp('ConfigFile',p.Parameters)); +perm(1) = indconf; perm(indconf) = 1; -extraParameters = fieldnames (p.Unmatched); -extraValues = struct2cell(p.Unmatched); +results = orderfields(p.Results,perm); +unmatched = p.Unmatched; + +parameters = fieldnames (results); +values = struct2cell(results); + +extraParameters = fieldnames (unmatched); +extraValues = struct2cell(unmatched); ReconFile = p.Results.ReconFile; BitstreamFile = p.Results.BitstreamFile; @@ -43,31 +51,21 @@ for file={ReconFile,BitstreamFile,LogFile} end end -try - argList = paramToArg([parameters;extraParameters],[values;extraValues]); - command = [TAppEncoder,' ',argList]; - disp(command) - status = system(command); - if status - error('Execution with extra parameters failed, trying execution without'); - end -catch - argList = paramToArg(parameters,values); - system([TAppEncoder,' ',argList]); -end +argList = paramToArg([parameters;extraParameters],[values;extraValues]); +command = [TAppEncoder,' ',argList]; +disp(command) +status = system(command); +if status, error('HEVC Error'); end end function argList = paramToArg(parameters,values) -indConf = cellfun(@(str) strcmp(str,'ConfigFile'),parameters); -indLog = cellfun(@(str) strcmp(str,'LogFile' ),parameters); -ind = indConf|indLog; +indLog = strcmp(parameters,'LogFile'); ind = indLog; -argConf = strjoin(['-c',values(indConf)]); argLog = strjoin(['>' ,values(indLog) ]); argList = cellfun(@(param,val) ['--',param,'=',val],... parameters(~ind),values(~ind),'UniformOutput',false); -argList = [argConf;argList;argLog]; +argList = [argList;argLog]; argList = strjoin(argList(:)); end \ No newline at end of file