1 /* -----------------------------------------------------------------------------
2 The copyright in this software is being made available under the BSD
3 License, included below. No patent rights, trademark rights and/or
4 other Intellectual Property Rights other than the copyrights concerning
5 the Software are granted under this license.
6
7 For any license concerning other Intellectual Property rights than the software,
8 especially patent licenses, a separate Agreement needs to be closed.
9 For more information please contact:
10
11 Fraunhofer Heinrich Hertz Institute
12 Einsteinufer 37
13 10587 Berlin, Germany
14 www.hhi.fraunhofer.de/vvc
15 vvc@hhi.fraunhofer.de
16
17 Copyright (c) 2018-2021, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
18 All rights reserved.
19
20 Redistribution and use in source and binary forms, with or without
21 modification, are permitted provided that the following conditions are met:
22
23 * Redistributions of source code must retain the above copyright notice,
24 this list of conditions and the following disclaimer.
25 * Redistributions in binary form must reproduce the above copyright notice,
26 this list of conditions and the following disclaimer in the documentation
27 and/or other materials provided with the distribution.
28 * Neither the name of Fraunhofer nor the names of its contributors may
29 be used to endorse or promote products derived from this software without
30 specific prior written permission.
31
32 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
36 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
40 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
42 THE POSSIBILITY OF SUCH DAMAGE.
43
44
45 ------------------------------------------------------------------------------------------- */
46
47 /** \file dtrace_codingstruct.h
48 * \brief Easy to use dtrace calls concerning coding structures
49 */
50
51 #pragma once
52
53 #include "dtrace.h"
54 #include "dtrace_next.h"
55
56 #include "CommonLib/CommonDef.h"
57 #include "CommonLib/CodingStructure.h"
58 #include "CommonLib/Slice.h"
59 #include "CommonLib/Mv.h"
60 #include "CommonLib/Unit.h"
61 #include "CommonLib/UnitTools.h"
62
63 #include <cmath>
64
65 namespace vvdec
66 {
67
68 #if ENABLE_TRACING
69
dtracePicComp(DTRACE_CHANNEL channel,CodingStructure & cs,const CPelUnitBuf & pelUnitBuf,ComponentID compId)70 inline void dtracePicComp( DTRACE_CHANNEL channel, CodingStructure& cs, const CPelUnitBuf& pelUnitBuf, ComponentID compId )
71 {
72 if( !g_trace_ctx ) return;
73 if( pelUnitBuf.chromaFormat == CHROMA_400 && compId != COMPONENT_Y ) return;
74 const Pel* piSrc = pelUnitBuf.bufs[compId].buf;
75 ptrdiff_t uiStride = pelUnitBuf.bufs[compId].stride;
76 uint32_t uiWidth = pelUnitBuf.bufs[compId].width;
77 uint32_t uiHeight = pelUnitBuf.bufs[compId].height;
78 uint32_t uiChromaScaleX = getComponentScaleX( compId, pelUnitBuf.chromaFormat );
79 uint32_t uiChromaScaleY = getComponentScaleY( compId, pelUnitBuf.chromaFormat );
80
81 DTRACE ( g_trace_ctx, channel, "\n%s: poc = %d, size=%dx%d\n\n", g_trace_ctx->getChannelName(channel), cs.picture->poc, uiWidth, uiHeight );
82 DTRACE_FRAME_BLOCKWISE( g_trace_ctx, channel, piSrc, uiStride, uiWidth, uiHeight, cs.sps->getMaxCUWidth() >> uiChromaScaleX, cs.sps->getMaxCUHeight() >> uiChromaScaleY);
83 }
84
85 #define DTRACE_PIC_COMP(...) dtracePicComp( __VA_ARGS__ )
86 #define DTRACE_STAT(...) dtraceComprPicStat(__VA_ARGS__)
87
88 #else
89
90 #define DTRACE_STAT(...)
91 #define DTRACE_PIC_COMP(...)
92
93 #endif
94
95 }
96