Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 4a89bd5a authored by DIB Elian's avatar DIB Elian
Browse files

Deal with HEVC "-c" parameter

parent 0f798f3f
No related branches found
No related tags found
No related merge requests found
...@@ -55,7 +55,7 @@ if encode ...@@ -55,7 +55,7 @@ if encode
HEVCp.addParameter('QP' ,'30' ,@ischar); HEVCp.addParameter('QP' ,'30' ,@ischar);
HEVCp.addParameter('WarnUnknowParameter','0' ,@ischar); HEVCp.addParameter('WarnUnknowParameter','0' ,@ischar);
if decode if decode
HEVCp.addParameter('ReconFile' ,'rec.yuv' ,@ischar); HEVCp.addParameter('ReconFile' ,'rec.yuv' ,@ischar);
end end
elseif decode elseif decode
HEVCp.addParameter('BitstreamFile' ,'bit.hevc',@ischar); HEVCp.addParameter('BitstreamFile' ,'bit.hevc',@ischar);
...@@ -70,27 +70,19 @@ HEVCp.parse(codecp.Unmatched); ...@@ -70,27 +70,19 @@ HEVCp.parse(codecp.Unmatched);
HEVCParams = HEVCp.Results; HEVCParams = HEVCp.Results;
extraHEVCParams = HEVCp.Unmatched; extraHEVCParams = HEVCp.Unmatched;
% Make sure ConfigFile is the first parameter to set default values
if encode
perm = 1:numel(HEVCp.Parameters);
indconf = find(strcmp('ConfigFile',HEVCp.Parameters));
perm(1) = indconf; perm(indconf) = 1;
HEVCParams = orderfields(HEVCParams,perm);
end
% Make sure to create output folders before running executable % Make sure to create output folders before running executable
[folder,~,~] = fileparts(HEVCp.Results.BitstreamFile); [folder,~,~] = fileparts(HEVCParams.BitstreamFile);
if ~exist(folder,'dir') if ~exist(folder,'dir')
mkdir(folder); mkdir(folder);
end end
if decode if decode
[folder,~,~] = fileparts(HEVCp.Results.ReconFile); [folder,~,~] = fileparts(HEVCParams.ReconFile);
if ~exist(folder,'dir') if ~exist(folder,'dir')
mkdir(folder); mkdir(folder);
end end
end end
[LogFolder,LogName,~] = fileparts(HEVCp.Results.BitstreamFile); [LogFolder,LogName,~] = fileparts(HEVCParams.BitstreamFile);
LogFileEnc = fullfile(LogFolder,[LogName,'_enc.rtf']); LogFileEnc = fullfile(LogFolder,[LogName,'_enc.rtf']);
LogFileDec = fullfile(LogFolder,[LogName,'_dec.rtf']); LogFileDec = fullfile(LogFolder,[LogName,'_dec.rtf']);
...@@ -98,12 +90,14 @@ LogFileDec = fullfile(LogFolder,[LogName,'_dec.rtf']); ...@@ -98,12 +90,14 @@ LogFileDec = fullfile(LogFolder,[LogName,'_dec.rtf']);
HEVCArgList = paramToArgList(HEVCParams); HEVCArgList = paramToArgList(HEVCParams);
extraHEVCArgList = paramToArgList(extraHEVCParams); extraHEVCArgList = paramToArgList(extraHEVCParams);
% Prompt in terminal and write in log file
if ispc if ispc
redirect = @(logfile) ['> "',logfile,'" | type "' logfile, '"']; redirect = @(logfile) ['> "',logfile,'" | type "' logfile, '"'];
elseif isunix elseif isunix
redirect = @(logfile) ['| tee ' ,LogFile]; redirect = @(logfile) ['| tee ' ,LogFile];
end end
% Execute command
if encode if encode
command = ['"' TApp,'" ',HEVCArgList,' ',extraHEVCArgList,' ',redirect(LogFileEnc)]; command = ['"' TApp,'" ',HEVCArgList,' ',extraHEVCArgList,' ',redirect(LogFileEnc)];
elseif decode elseif decode
...@@ -113,6 +107,7 @@ end ...@@ -113,6 +107,7 @@ end
disp(command) disp(command)
status = system(command); status = system(command);
% Try without extra HEVC parameters if HEVC error
if status if status
if encode if encode
command = ['"' TApp,'" ',HEVCArgList,' ',redirect(LogFileEnc)]; command = ['"' TApp,'" ',HEVCArgList,' ',redirect(LogFileEnc)];
...@@ -126,6 +121,7 @@ if status ...@@ -126,6 +121,7 @@ if status
end end
end end
% Read compression statistics from log file
try try
[nbBits,peaksnr] = HEVC.parseLog(LogFileEnc); [nbBits,peaksnr] = HEVC.parseLog(LogFileEnc);
catch catch
...@@ -135,10 +131,25 @@ end ...@@ -135,10 +131,25 @@ end
end end
function argList = paramToArgList(Params) function argList = paramToArgList(Params)
% Get parameters and arguments
parameters = fieldnames (Params); parameters = fieldnames (Params);
values = struct2cell(Params); values = struct2cell(Params);
% Deal with '-c' being the single command line parameter for configuration file
indcfg = strcmp(parameters,'ConfigFile');
if any(indcfg)
argcfg = ['-c "',values{indcfg},'"'];
else
argcfg = '';
end
parameters = parameters(~indcfg);
values = values (~indcfg);
% Build command line argument list
argList = cellfun(@(param,val) ['--',param,'="',val,'"'],parameters,values,'UniformOutput',false); argList = cellfun(@(param,val) ['--',param,'="',val,'"'],parameters,values,'UniformOutput',false);
argList = strjoin(argList(:)); argList = strjoin([argcfg;argList(:)]);
end end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment