Mentions légales du service

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

Changed HEVC Class into Wrapper under HEVC package

parent 48c43b72
Branches
No related tags found
No related merge requests found
...@@ -2,3 +2,5 @@ ...@@ -2,3 +2,5 @@
bin/ bin/
data/ data/
*.asv
classdef HEVC
%HEVC Summary of this class goes here
% Detailed explanation goes here
properties
params
extraParams
end
methods
function obj = HEVC(varargin)
p = inputParser; p.KeepUnmatched = true;
p.addParameter('ConfigFile' ,'Intra.cfg',@ischar);
p.addParameter('InputFile' ,'ref.yuv' ,@ischar);
p.addParameter('BitstreamFile' ,'str.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('InputChromaFormat','420' ,@ischar);
p.addParameter('FrameRate' ,'60' ,@ischar);
p.addParameter('FrameSkip' ,'0' ,@ischar);
p.addParameter('FramesToBeEncoded','1' ,@ischar);
p.addParameter('QP' ,'32' ,@ischar);
% Add additional parameters here
p.parse(varargin{:});
obj.params = p.Results;
obj.extraParams = p.Unmatched;
end
encode(obj,varargin)
end
end
classdef Wrapper
%WRAPPER Summary of this class goes here
% Detailed explanation goes here
properties
params
extraParams
end
methods
function obj = Wrapper(varargin)
[WrapperDir,~,~] = fileparts(mfilename('fullpath'));
defaultCfg = fullfile(WrapperDir,'..','cfg','intra.cfg');
p = inputParser; p.KeepUnmatched = true;
p.addParameter('ConfigFile' ,defaultCfg,@ischar);
p.addParameter('InputFile' ,'ref.yuv' ,@ischar);
p.addParameter('BitstreamFile' ,'str.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('InputChromaFormat','420' ,@ischar);
p.addParameter('FrameRate' ,'60' ,@ischar);
p.addParameter('FrameSkip' ,'0' ,@ischar);
p.addParameter('FramesToBeEncoded','1' ,@ischar);
p.addParameter('QP' ,'32' ,@ischar);
% Add additional default parameters here
p.parse(varargin{:});
obj.params = p.Results;
obj.extraParams = p.Unmatched;
end
encode(obj,varargin)
decode(obj,varargin)
end
end
function decode(obj,varargin)
%DECODE Summary of this function goes here
% Detailed explanation goes here
HEVC.decode(obj.params,obj.extraParams,varargin{:});
end
File moved
function decode(BitstreamFile,ReconFile,varargin) function decode(varargin)
%DECODE Summary of this function goes here %DECODE Summary of this function goes here
% Detailed explanation goes here % Detailed explanation goes here
[HEVCDir,~,~] = fileparts(mfilename('fullpath')); [HEVCDir,~,~] = fileparts(mfilename('fullpath'));
TAppEncoder = fullfile(HEVCDir,'bin','TAppDecoder.exe'); TAppDecoder = fullfile(HEVCDir,'bin','TAppDecoder.exe');
p = inputParser; p.KeepUnmatched = true; p = inputParser; p.KeepUnmatched = true; p.StructExpand = true;
p.addRequired ('BitstreamFile' ,@ischar); p.addParameter('BitstreamFile','bit.hevc',@ischar);
p.addRequired ('ReconFile' ,@ischar); p.addParameter('ReconFile' ,'rec.yuv' ,@ischar);
p.addParameter('SkipFrames','0',@ischar); p.addParameter('SkipFrames' ,'0' ,@ischar);
% Add additional parameters here % Add additional default parameters here
p.parse(BitstreamFile,ReconFile,varargin{:}); p.parse(varargin{:});
parameters = fieldnames (p.Results); parameters = fieldnames (p.Results);
values = struct2cell(p.Results); values = struct2cell(p.Results);
...@@ -21,13 +21,13 @@ extraValues = struct2cell(p.Unmatched); ...@@ -21,13 +21,13 @@ extraValues = struct2cell(p.Unmatched);
try try
argList = paramToArg([parameters;extraParameters],[values;extraValues]); argList = paramToArg([parameters;extraParameters],[values;extraValues]);
status = system([TAppEncoder,' ',argList]); status = system([TAppDecoder,' ',argList]);
if status if status
error('Execution with extra parameters failed, trying execution without'); error('Execution with extra parameters failed, trying execution without');
end end
catch catch
argList = paramToArg(parameters,values); argList = paramToArg(parameters,values);
system([TAppEncoder,' ',argList]); system([TAppDecoder,' ',argList]);
end end
function argList = paramToArg(parameters,values) function argList = paramToArg(parameters,values)
......
...@@ -4,23 +4,24 @@ function encode(varargin) ...@@ -4,23 +4,24 @@ function encode(varargin)
[HEVCDir,~,~] = fileparts(mfilename('fullpath')); [HEVCDir,~,~] = fileparts(mfilename('fullpath'));
TAppEncoder = fullfile(HEVCDir,'bin','TAppEncoder.exe'); TAppEncoder = fullfile(HEVCDir,'bin','TAppEncoder.exe');
defaultCfg = fullfile(HEVCDir,'cfg','intra.cfg');
p = inputParser; p.KeepUnmatched = true; p.StructExpand = true; p = inputParser; p.KeepUnmatched = true; p.StructExpand = true;
p.addParameter('ConfigFile' ,'Intra.cfg',@ischar); p.addParameter('ConfigFile' ,defaultCfg,@ischar);
p.addParameter('InputFile' ,'ref.yuv' ,@ischar); p.addParameter('InputFile' ,'ref.yuv' ,@ischar);
p.addParameter('BitstreamFile' ,'bit.hevc' ,@ischar); p.addParameter('BitstreamFile' ,'bit.hevc',@ischar);
p.addParameter('ReconFile' ,'rec.yuv' ,@ischar); p.addParameter('ReconFile' ,'rec.yuv' ,@ischar);
p.addParameter('LogFile' ,'log.rtf' ,@ischar); p.addParameter('LogFile' ,'log.rtf' ,@ischar);
p.addParameter('SourceWidth' ,'512' ,@ischar); p.addParameter('SourceWidth' ,'512' ,@ischar);
p.addParameter('SourceHeight' ,'512' ,@ischar); p.addParameter('SourceHeight' ,'512' ,@ischar);
p.addParameter('InputBitDepth' ,'8' ,@ischar); p.addParameter('InputBitDepth' ,'8' ,@ischar);
p.addParameter('InputChromaFormat','420' ,@ischar); p.addParameter('InputChromaFormat','420' ,@ischar);
p.addParameter('FrameRate' ,'60' ,@ischar); p.addParameter('FrameRate' ,'60' ,@ischar);
p.addParameter('FrameSkip' ,'0' ,@ischar); p.addParameter('FrameSkip' ,'0' ,@ischar);
p.addParameter('FramesToBeEncoded','1' ,@ischar); p.addParameter('FramesToBeEncoded','1' ,@ischar);
p.addParameter('QP' ,'30' ,@ischar); p.addParameter('QP' ,'30' ,@ischar);
% Add additional parameters here % Add additional default parameters here
p.parse(varargin{:}); p.parse(varargin{:});
...@@ -43,11 +44,9 @@ end ...@@ -43,11 +44,9 @@ end
function argList = paramToArg(parameters,values) function argList = paramToArg(parameters,values)
indConf = cellfun(@(str) strcmp(str,'ConfigFile'),parameters); indConf = cellfun(@(str) strcmp(str,'ConfigFile'),parameters);
indLog = cellfun(@(str) strcmp(str,'LogFile'),parameters); indLog = cellfun(@(str) strcmp(str,'LogFile' ),parameters);
ind = indConf|indLog; ind = indConf|indLog;
values{indConf} = fullfile(HEVCDir,'cfg',values{indConf});
argConf = strjoin(['-c',values(indConf)]); argConf = strjoin(['-c',values(indConf)]);
argLog = strjoin(['>' ,values(indLog) ]); argLog = strjoin(['>' ,values(indLog) ]);
argList = cellfun(@(param,val) ['--',param,'=',val],... argList = cellfun(@(param,val) ['--',param,'=',val],...
......
function [frames,framesRef,framesRec] = encodeLF(LF,name,varargin)
%ENCODELF Summary of this function goes here
% Detailed explanation goes here
colSpaces = {'yuv','ycbcr','lab','hsv','rgb'};
subSamps = {'420','444','422','400'};
precisions = {'uint8','uint16','uint32','uint64',...
'int8', 'int16', 'int32', 'int64',...
'single','double'};
% Create input parser scheme
params = inputParser;
params.StructExpand = true;
params.KeepUnmatched = true;
params.addParameter('colSpace' ,colSpaces{1} ,@(x) any(validatestring(x,colSpaces )));
params.addParameter('subSamp' ,subSamps{1} ,@(x) any(validatestring(x,subSamps )));
params.addParameter('precision' ,precisions{1},@(x) any(validatestring(x,precisions)));
% Parse arguments
params.parse(varargin{:});
yuvParams = params.Results;
extraParams = params.Unmatched;
if isfield(extraParams,'InputChromaFormat')
ICF = extraParams.InputChromaFormat;
SS = yuvParams.subSamp;
if ~strcmp(ICF,SS)
warning(['Conflicting SubSamp and InputChromaFormat parameters',...
' , choosing InputChromaFormat']);
yuvParams.subSamp = ICF;
end
end
% Change 5D LF to a collection of 2D frames
frames = LFToFrames(LF);
% Convert each frame according to given parameters
framesRef = yuv.convert(frames,yuvParams);
% Write frames as a YUV sequence
[imgRes,imgSize] = yuv.write(framesRef,name,yuvParams,'subName','_ref');
% Convert inputs for HEVC
HEVCparams = extractHEVCParams(name,yuvParams);
% Encode frames using HEVC
HEVC.encode(HEVCparams,extraParams);
% Recover frames
framesRec = yuv.read(name,imgRes,imgSize,yuvParams,'subName','_rec');
%% Auxiliary functions
function frames = LFToFrames(LF)
s = size(LF);
s(numel(s)+1:5)=1;
frames = mat2cell(LF,ones(1,s(1)),ones(1,s(2)),s(3),s(4),s(5));
end
function params = extractHEVCParams(name,yuvParams)
colSpace = yuvParams.colSpace;
subSamp = yuvParams.subSamp;
resCell = num2cell(imgRes);
sizeCell = num2cell(imgSize);
fullName = [resCell,sizeCell];
fullName = cellfun(@num2str,fullName,'UniformOutput',false);
fullName = strjoin([name fullName subSamp],'_');
params.InputFile = [fullName,'_ref','.',colSpace];
params.BitstreamFile = [fullName, '.','hevc' ];
params.ReconFile = [fullName,'_rec','.',colSpace];
params.LogFile = [fullName, '.','rtf' ];
params.SourceWidth = num2str(imgSize(2));
params.SourceHeight = num2str(imgSize(1));
params.FramesToBeEncoded = num2str(prod(imgRes));
params.InputChromaFormat = num2str(subSamp);
end
end
log.rtf 0 → 100644
HM software: Encoder Version [16.10] (including RExt)[Windows][VS 1900][64 bit]
Input File : ref.yuv
Bitstream File : str.hevc
Reconstruction File : rec.yuv
Real Format : 512x512 60Hz
Internal Format : 512x512 60Hz
Sequence PSNR output : Linear average only
Sequence MSE output : Disabled
Frame MSE output : Disabled
Cabac-zero-word-padding : Enabled
Frame/Field : Frame based coding
Frame index : 0 - 0 (1 frames)
Profile : main-RExt (main_444)
CU size / depth / total-depth : 64 / 4 / 4
RQT trans. size (min / max) : 4 / 32
Max RQT depth inter : 3
Max RQT depth intra : 3
Min PCM size : 8
Motion search range : 64
Intra period : 1
Decoding refresh type : 0
QP : 32.00
Max dQP signaling depth : 0
Cb QP Offset : 0
Cr QP Offset : 0
QP adaptation : 0 (range=0)
GOP size : 1
Input bit depth : (Y:8, C:8)
MSB-extended bit depth : (Y:8, C:8)
Internal bit depth : (Y:8, C:8)
PCM sample bit depth : (Y:8, C:8)
Intra reference smoothing : Enabled
diff_cu_chroma_qp_offset_depth : -1
extended_precision_processing_flag : Disabled
implicit_rdpcm_enabled_flag : Enabled
explicit_rdpcm_enabled_flag : Enabled
transform_skip_rotation_enabled_flag : Enabled
transform_skip_context_enabled_flag : Enabled
cross_component_prediction_enabled_flag: Disabled
high_precision_offsets_enabled_flag : Enabled
persistent_rice_adaptation_enabled_flag: Enabled
cabac_bypass_alignment_enabled_flag : Disabled
log2_sao_offset_scale_luma : 0
log2_sao_offset_scale_chroma : 0
Cost function: : Lossy coding (default)
RateControl : 0
WPMethod : 0
Max Num Merge Candidates : 5
TOOL CFG: IBD:0 HAD:1 RDQ:1 RDQTS:1 RDpenalty:0 SQP:0 ASR:0 MinSearchWindow:8 RestrictMESampling:0 FEN:1 ECU:0 FDM:1 CFM:0 ESD:0 RQT:1 TransformSkip:1 TransformSkipFast:1 TransformSkipLog2MaxSize:2 Slice: M=0 SliceSegment: M=0 CIP:0 SAO:1 PCM:0 TransQuantBypassEnabled:0 WPP:0 WPB:0 PME:2 WaveFrontSynchro:0 WaveFrontSubstreams:1 ScalingList:0 TMVPMode:1 AQpS:0 SignBitHidingFlag:1 RecalQP:0
Non-environment-variable-controlled macros set as follows:
RExt__DECODER_DEBUG_BIT_STATISTICS = 0
RExt__HIGH_BIT_DEPTH_SUPPORT = 1
RExt__HIGH_PRECISION_FORWARD_TRANSFORM = 1
O0043_BEST_EFFORT_DECODING = 0
ME_ENABLE_ROUNDING_OF_MVS = 1
U0040_MODIFIED_WEIGHTEDPREDICTION_WITH_BIPRED_AND_CLIPPING = 1
failed to open Input YUV file
function [nbBits_HEVC, PSNR_HEVC, ET_HEVC] = parse_log(filename,nbFrames) function [nbBits_HEVC, PSNR_HEVC, ET_HEVC] = parseLog(filename,nbFrames)
fid = fopen(filename); fid = fopen(filename);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment