3 This section defines the process for unpacking (parsing, entropy decoding and
4 inverse quantizing) wavelet transform coefficient data from the Dirac stream.
5 Wavelet coefficients shall be signed integer values and shall be extracted
6 using the integer VLC and (optionally) arithmetic decoding functions defined in annex A.
7 The use of arithmetic coding within a picture shall be as signaled by the parse codes
8 defined in Section~
\ref{parseinfoheader
}. The result of this process shall be a set of fully
9 populated wavelet subband data arrays, as defined in
10 Section~
\ref{wltdecodeconventions
}.
12 Wavelet coefficients shall be packed in the bitstream in one of two possible formats:
14 \item In the core syntax, coefficients shall be grouped within individual subbands,
15 representing a range of spatial frequencies, from the lowest to the highest. A full set of
16 subbands shall be encoded for each video component in turn.
17 \item In the low delay syntax, coefficients shall be grouped into slices that represent
18 coefficients pertaining to an area of the picture. Each slice shall contain data for all video
19 components and spatial frequency bands. Unpacking a slice allows an area of picture to
20 be extracted without extracting (or even receiving) the remaining picture data.
23 The overall process for unpacking transform data shall be as follows:
25 \begin{pseudo
}{transform
\_data}{}
26 \bsIF{is
\_low\_delay()==
\false}
27 \bsCODE{\YTransform = core
\_transform\_data(Y)
}{\ref{transformdec
}}
28 \bsCODE{\COneTransform = core
\_transform\_data(C1)
}{\ref{transformdec
}}
29 \bsCODE{\CTwoTransform = core
\_transform\_data(C2)
}{\ref{transformdec
}}
31 \bsCODE{low
\_delay\_transform\_data()
}{\ref{ldpicture
}}
35 Unpacked wavelet coefficient data shall be stored in the state variables $
\YTransform$,
36 $COneTransform$ and $CTwoTransform$ for the IDWT process (Section~
\ref{idwt
}).
38 \subsection{Subband data structures
}
39 \label{wltdecodeconventions
}
41 Subband data shall be ordered by level (
0,
1,
2,
3 etc) and orientation (LL, HL, LH and HH). In level
0, only the LL orientation shall be available (known also as the DC band); in the other levels only the HL, LH and HH orientations shall be available.
43 The
0-LL subband shall be presented first in each slice (low delay coding) or component (core syntax coding). Within each subband depth level, the orientation order shall be x-HL, x-LH, x-HH (where ‘x’ is the transform depth level).
45 The subbands partition the spatial frequencies by orientation and level so that a four-level subband array is as illustrated in Figure
\ref{fig:orientlevel
}.
48 \setlength{\unitlength}{1em
}
51 \begin{picture
}(
25,
35)
54 \multiput(
0,
0)(
16,
0)
{3}%
56 \multiput(
0,
0)(
0,
16)
{3}%
60 \put(
0,
24)
{\line(
1,
0)
{16}}
61 \put(
8,
16)
{\line(
0,
1)
{16}}
64 \put(
0,
28)
{\line(
1,
0)
{8}}
65 \put(
4,
24)
{\line(
0,
1)
{8}}
68 \put(
0,
30)
{\line(
1,
0)
{4}}
69 \put(
2,
28)
{\line(
0,
1)
{4}}
75 \put(
23,
36)
{\vector(
0,-
1)
{3}}
78 \put(
12,
36)
{\vector(
0,-
1)
{3}}
81 \put(
6,
36)
{\vector(
0,-
1)
{3}}
84 \put(
3,
36)
{\vector(
0,-
1)
{3}}
86 %Put decomposition numbers
96 \put(
2.2,
31)
{\tiny 1-HL
}
97 \put(
0.2,
29)
{\tiny 1-LH
}
98 \put(
2.2,
29)
{\tiny 1-HH
}
99 \put(
0.2,
31)
{\tiny 0-LL
}
103 \caption{Subband decomposition of the spatial frequency domain showing subband
104 numbering, for a
4-level wavelet decomposition
}\label{fig:orientlevel
}
109 \subsubsection{Wavelet data initialisation
}
113 This section defines the $initialise
\_wavelet\_data(comp)$ process, which returns a structure which will
114 contain the wavelet coefficients for the component (Y, C1 or C2) indicated by $comp$.
116 The coefficient data shall comprise the four dimensional array $coeff
\_data$, where
117 individual subbands shall be two-dimensional arrays accessed by level $level$ and orientation $orient$: e.g.
118 \
[band = coeff
\_data[level
][orient
] \
]
120 Valid levels shall be integer values in the range
0 to $
\TransformDepth$ inclusive.
122 Level
0 shall consists of a single subband with orientation
\LL.
124 All other levels shall consist of
3 subbands of orientation
\HL,
\LH
125 and
\HH in that order within the Dirac stream.
127 The orientations correspond to either low- or high-pass filtering
128 horizontally and vertically: so e.g. the
\LH band consists of coefficients derived
129 from horizontal low-pass filtering and vertical high-pass filtering.
131 Each subband array shall be initialised so that:
133 \width(coeff
\_data[level
][orient
]) & = & subband
\_width(level,comp) \\
134 \height(coeff
\_data[level
][orient
]) & = & subband
\_height(level,comp)
137 as specified in Section~
\ref{subbandwidthheight
}. These dimensions correspond
138 to a wavelet transform being performed on a copy of the component data which
139 has been padded (if necessary) so that its
140 dimensions are a multiple of $
2^
{\TransformDepth}$.
142 Individual subband coefficients shall be signed integers accessed by vertical and
143 horizontal coordinates within the subband, e.g.:
144 \
[c = coeff
\_data[level
][orient
][y
][x
]\
]
146 for coordinates $(x,y)$ such that
148 0\leq x<subband
\_width(level,comp) \\
149 0\leq y<subband
\_height(level,comp)
152 \subsubsection{Subband dimensions
}
153 \label{subbandwidthheight
}
155 This section defines the values of the $subband
\_width(level, comp)$ and $subband
\_height(level,comp)$
156 functions, giving the width and height of subbands at a given level for a given component, and hence the range
157 of subband vertical and horizontal indices.
161 w & = &
\LumaWidth \\
167 w & = &
\ChromaWidth \\
168 h & = &
\ChromaHeight
171 The padded dimensions of the component shall be defined by:
173 scale & = &
2^
\TransformDepth \\
174 pw & = & scale*((w+scale-
1)//scale)\\
175 ph & = & scale*((h+scale-
1)//scale)
180 subband
\_width(level) & = & pw//
2^
{\TransformDepth} \\
181 subband
\_height(level) & = & ph//
2^
{\TransformDepth}
186 subband
\_width(level) & = & pw//
2^
{\TransformDepth-level+
1}\\
187 subband
\_height(level) & = & ph//
2^
{\TransformDepth-level+
1}
191 In encoding, these padded dimensions may be achieved by padding the
192 component data up to the padded dimensions and applying the forward
193 Discrete Wavelet Transform (the inverse of the operations specified in
194 Section~
\ref{idwt
}). Any values may be used for the padded data, although
195 the choice will affect wavelet coefficients at the right and bottom
196 edges of the subbands. Good results, in compression terms, may be obtained
197 by using edge extension for intra pictures and zero extension for inter
198 pictures. A poor choice of padding may cause visible artefacts near the
199 bottom and right edges at high levels of compression.
202 \subsection{Inverse quantisation
}
205 This section defines the operation of inverse quantisation, which scales the
206 dynamic range of unpacked wavelet coefficients according to a pre-determined factor.
207 The inverse quantisation operation is common to both the low-delay and core syntax.
209 The $inverse
\_quant()$ function shall be defined as follows:
211 \begin{pseudo
}{inverse
\_quant}{quantised
\_coeff, quant
\_index}
212 \bsCODE{magnitude = |
{quantised
\_coeff}|
}
214 \bsCODE{magnitude *= quant
\_factor(quant
\_index)
}{\ref{quantfacs
}}
215 \bsCODE{magnitude += quant
\_offset(quant
\_index)
}{\ref{quantfacs
}}
216 \bsCODE{magnitude +=
2}
217 \bsCODE{magnitude = magnitude//
4}
219 \bsRET{\sign( quantised
\_coeff )*magnitude
}
224 \item Dirac quantisation is an integer approximation of dead-zone quantisation,
225 in which a value is quantised as
226 \
[\left| x
\right| // qf\
]
228 \
[-
\left| x
\right| // qf\
]
229 Since this process involves rounding down, the inverse quantisation process adds
230 an offset to reconstructed values after multiplying by $qf$. This produces a
231 value on average closer to the original value.
232 \item The pseudocode description separates inverse quantisation from coefficient unpacking. However,
233 since dead-zone quantisation is used, the $inverse
\_quant()$ function must compute
234 the magnitude. Hence it is more efficient to first extract the coefficient magnitude,
235 then inverse quantise, and then extract the coefficient sign.
236 \item In the low delay syntax, the quantisation index is limited to
6 bits,
237 i.e. a maximum value of
63. In the core syntax this limit will also suffice
238 for
8 bit data and a
4-level transform, but the maximum value will in general
239 depend upon the video bit depth, the type of wavelet filter and the transform
240 depth. A value of
127 will account for most practical situations.
244 \subsubsection{Quantisation factors and offsets
}
247 This section defines the operation of the $quant
\_factor()$ and
248 $quant
\_offset()$ functions for performing inversion quantisation.
250 Quantisation factors shall be determined as follows:
252 \begin{pseudo
}{quant
\_factor}{index
}
253 \bsCODE{base =
2^
{index//
4}}
254 \bsIF{ (index\%
4)==
0 }
256 \bsELSEIF{ (index\%
4)==
1 }
257 \bsRET{(
503829*base+
52958)//
105917}
258 \bsELSEIF{ (index\%
4)==
2 }
259 \bsRET{(
665857*base+
58854)//
117708}
260 \bsELSEIF{ (index\%
4)==
3 }
261 \bsRET{(
440253*base+
32722)//
65444}
265 For intra pictures, offsets are approximately $
1/
2$ of the
266 quantisation factors, and for inter pictures they are $
3/
8$ - these
267 mark the reconstruction point within the quantisation interval:
269 \begin{pseudo
}{quant
\_offset}{index
}
277 \bsCODE{ offset=(quant
\_factor(index)+
1)//
2 }
280 \bsCODE{ offset=(quant
\_factor(index)*
3+
4)//
8 }
286 The value of $index$ passed to both functions shall be greater than or equal
0.
289 The quantisation offsets have been selected so as to make inverse quantisation
290 and re-quantisation by the same quantisation factor transparent. This requires that
291 \
[3\leq quant
\_offset+
2<quant
\_factor\
] -- hence the special conditions for
292 quantisation indexes
0 and
1.
295 \subsection{Intra DC subband prediction
}
296 \label{intradcprediction
}
298 This section defines the operation of the $intra
\_dc\_prediction(band)$ function
299 for reconstructing values within Intra picture DC subbands using spatial prediction.
301 This function may be applied once all coefficients within the DC
302 band have been unpacked, although it may be applied progressively to each coefficient
303 as soon as it has been unpacked.
305 Intra DC values shall be derived by spatial prediction using the mean of the
306 three values to the left, top-left and above a coefficient (where available).
308 The Intra DC subband prediction process shall be defined as follows:
310 \begin{pseudo
}{intra
\_dc\_prediction}{band
}
311 \bsCODE{prediction =
0 }
312 \bsFOR{v=
0}{\height(band)-
1}
313 \bsFOR{h=
0}{\width(band)-
1}
314 \bsIF{h>
0 \text{ \bf and
} v>
0}
315 \bsCODE{prediction=
\mean(band
[v
][h-
1],band
[v-
1][h-
1],band
[v-
1][h
])
}
316 \bsELSEIF{h>
0 \text{ \bf and
} v==
0}
317 \bsCODE{prediction=band
[0][h-
1]}
318 \bsELSEIF{h==
0 \text{ \bf and
} v>
0}
319 \bsCODE{prediction=band
[v-
1][0]}
321 \bsCODE{prediction =
0}
323 \bsCODE{band
[v
][h
] += prediction
}
328 \subsection{Core syntax wavelet coefficient unpacking
}
332 This section defines the overall operation of the $core
\_transform\_data(comp)$ process
333 for unpacking the set of coefficient subbands corresponding
334 to a video component (Y, C1 or C2) of a picture in the core Dirac syntax,
335 according to the conventions set out in Section~
\ref{wltdecodeconventions
}.
338 In the Dirac core syntax, subband data shall be entropy coded. It shall be arranged by
339 level and orientation, from level
0 up to level
\TransformDepth. Coefficients may
340 be VLC or arithmetic coded. Where arithmetic coding is used, the unpacking process
341 for each subband is contingent on data from subbands of the same orientation in
342 the next lower level. This is the
{\em parent
} subband; the subband of the same orientation in the next
343 higher level is the
{\em child
} subband.
345 Unpacking an individual subband therefore requires prior unpacking of the parent subband,
346 and of its parent, and so on until level
1 is reached (unpacking level
1 subbands does not depend upon the single level
0 DC band).
349 The data for each subband consists of a subband header and a block of
350 coded coefficient data. The subband header contains a length code giving the number of
351 bytes of the block of coded data. The transform data can therefore be
352 parsed without invoking entropy decoding at all, since the length codes allow a
353 parser to skip from one subband header to the next.
357 \subsubsection{Overall process
}
358 The overall $core
\_transform\_data()$ process shall be defined as follows:
360 \begin{pseudo
}{core
\_transform\_data}{comp
}
361 \bsCODE{coeff
\_data=initialise
\_wavelet\_data(comp)
}{\ref{wltinit
}}
362 \bsCODE{byte
\_align()
}
363 \bsCODE{subband(coeff
\_data,
0,
\LL)
}{\ref{subbanddecodeprocess
}}
364 \bsFOR{level=
1}{\TransformDepth}
365 \bsFOREACH{orient
}{\HL,
\LH,
\HH}
366 \bsCODE{byte
\_align()
}
367 \bsCODE{subband(coeff
\_data, level, orient)
}{\ref{subbanddecodeprocess
}}
373 \subsubsection{Subbands
}
375 \label{subbanddecodeprocess
}
377 This section defines the process for unpacking coefficients of a specified level
378 and orientation $orient$.
380 The overall process shall consist of reading a byte-aligned header for each
381 subband, including a length code for the subsequent arithmetically-coded data.
382 Subband data shall be initialised to
0. If the length code is
0, the subband shall be
383 skipped and all data within it shall remain set to zero.
385 Intra DC bands are predicted, and so must additionally be reconstructed.
387 The subband unpacking process shall be defined as follows:
389 \begin{pseudo
}{subband
}{coeff
\_data, level, orient
}
390 \bsITEM{length
}{uint
}
391 \bsCODE{zero
\_subband\_data(coeff
\_data[level
][orient
])
}{\ref{zerosubband
}}
393 \bsCODE{byte
\_align()
}
395 \bsCODE{quant
\_index = read
\_uint()
}
396 \bsCODE{byte
\_align()
}
397 \bsCODE{subband
\_coeffs(coeff
\_data,level,orient,length,quant
\_index)
}{\ref{subbandcoeffs
}}
399 \bsIF{is
\_intra()
\text{ and
} level==
0}
400 \bsCODE{intra
\_dc\_prediction(coeff
\_data[level
][orient
])
}{\ref{intradcprediction
}}
404 \paragraph{Zero subband
}
406 $\ $
\newline$\ $
\newline
407 The $zero
\_subband()$ process shall sets all coefficients in a given subband to
0.
409 It shall be defined as follows:
411 \begin{pseudo
}{zero
\_subband\_data}{band
}
412 \bsFOR{y=
0}{\height(band)-
1}
413 \bsFOR{x=
0}{\width(band)-
1}
414 \bsCODE{band
[y
][x
] =
0}
419 \paragraph{Non-skipped subbands
}
420 \label{subbandcoeffs
}
421 $\ $
\newline$\ $
\newline
422 Data within subbands may be split into one or more rectangular codeblocks (Figure
\ref{codeblocks
}). Codeblocks shall be scanned in raster order across the subband
423 and coefficients shall be scanned in raster order within each codeblock.
426 [Include codeblock figure
\label{codeblocks
}]
429 The $subband
\_coeffs()$ process shall be defined as follows:
431 \begin{pseudo
}{subband
\_coeffs}{coeff
\_data,level,orient,length,quant
\_index}
432 \bsCODE{\ABitsLeft=
8*length
}
433 \bsIF{using
\_ac()==
\true}
435 \begin{array
}{l
} [\SignZero,
\SignPos,
\SignNeg,
\ZPZNFollowOne,\\
436 \ZPNNFollowOne,
\ZPFollowTwo,
\ZPFollowThree,
437 \ZPFollowFour,
\ZPFollowFive,
\ZPFollowSixPlus,\\
438 \NPZNFollowOne,
\NPNNFollowOne,
\NPFollowTwo,
439 \NPFollowThree,
\NPFollowFour,\\
440 \NPFollowFive,
\NPFollowSixPlus,
\CoeffData,
\ZeroCodeblock,\\
441 \QOffsetFollow,
\QOffsetData, \\
445 \bsCODE{initialise
\_arithmetic\_decoding(ctx
\_labels)
}{\ref{initarith
}}
447 \bsFOR{y=
0}{\CodeblocksY[level
]-
1}
448 \bsFOR{x=
0}{\CodeblocksX[level
]-
1}
449 \bsCODE{codeblock(coeff
\_data,level,orient,x,y,quant
\_index)
}{\ref{codeblocks
}}
452 \bsCODE{flush
\_inputb()
}{\ref{blockreadbit
}}
455 The key to the context labels is explained in Section~
\ref{selectcoeffcontext
}.
457 \subsubsection{Subband codeblocks
}
460 This section defines the operation of the process:
462 $codeblock(band,parent,level, orient,cx,cy,quant
\_index)$
464 This process shall unpack coefficients within the codeblock at position $(cx,cy)$.
465 The dimensions of the codeblock shall be as defined in Section~
\ref{codeblockdimensions
}.
466 The process for unpacking coefficients within the codeblock given these dimensions
467 shall be as defined in Section~
\ref{codeblockloop
}.
469 \paragraph{Codeblock dimensions
}
471 \label{codeblockdimensions
}
473 Each codeblock shall cover coefficients in the horizontal range $cb
\_left$ to
475 and in the vertical range $cb
\_top$ to $cb
\_bottom-
1$ where these values shall be
476 defined by the functions:
479 cb
\_left(x,band,level) & = & (
\width(band)*x)//
\CodeblocksX[level
]\\
480 cb
\_right(x,band,level) & = & (
\width(band)*(x+
1))//
\CodeblocksX[level
] \\
481 cb
\_top(y,band,level) & = & (
\height(band)*y)//
\CodeblocksY[level
] \\
482 cb
\_bottom(y,band,level) & = & (
\height(band)*(y+
1))//
\CodeblocksY[level
]
485 where $x$ and $y$ are the codeblock coordinates within the subband.
487 \paragraph{Codeblock unpacking loop
}
489 \label{codeblockloop
}
491 The codeblock unpacking process shall be defined as follows:
493 \begin{pseudo
}{codeblock
}{coeff
\_data,level,orient,cx,cy,quant
\_index}
494 \bsCODE{skipped=zero
\_flag(level)
}{\ref{zeroblockflag
}}
495 \bsIF{skipped==
\false}
496 \bsCODE{band = coeff
\_data[level
][orient
]}
497 \bsCODE{quant
\_index += codeblock
\_quant\_offset()
}{\ref{blockquantidx
}}
498 \bsFOR{y=cb
\_top(cy,band,level)
}{cb
\_bottom(cy,band,level)-
1}{\ref{codeblockdimensions
}}
499 \bsFOR{x=cb
\_left(cx,band,level)
}{cb
\_right(cx,band,level)-
1}{\ref{codeblockdimensions
}}
500 \bsCODE{coeff
\_unpack(coeff
\_data,level,orient,x,y,quant
\_index)
}{\ref{wltcoeff
}}
508 If the codeblock is skipped, then coefficients within that codeblock
511 The function $codeblock
\_quant\_offset()$ returns a signed value, but the
512 quantiser offset values coded in the stream shall be constrained so that the
513 reconstructed value of $quant
\_index$ shall be non-negative.
516 Codeblock quantisers are encoded differentially in the stream, and the
517 value of $quant
\_index$ is modified by this function (all variables)
518 are passed by reference). A decoder ought to check that the reconstructed value
519 of $quant
\_index$ falls within the bounds it supports.
522 \paragraph{Skipped codeblock flag
}
523 \label{zeroblockflag
}
524 $\ $
\newline$\ $
\newline
525 The skipped codeblock flag process shall be as follows:
527 \begin{pseudo
}{zero
\_flag}{level
}
528 \bsCODE{num
\_blocks=
\CodeblocksX[level
]*
\CodeblocksY[level
] }
529 \bsIF{num
\_blocks==
1}
531 \bsELSEIF{using
\_ac()==
\true}
532 \bsRET{ read
\_boola(
\ZeroCodeblock)
}
534 \bsRET{read
\_boolb()
}
538 If the number of codeblocks is
1, then $zero
\_flag()$ shall return $
\false$.
540 If arithmetic coding is employed, then the zero flag shall be decoded using
541 the context probability indicated by the $
\ZeroCodeblock$ label, as defined
542 in Annex~
\ref{arithreadbool
}.
544 \paragraph{Codeblock quantiser offset
}
545 $\ $
\newline$\ $
\newline
546 \label{blockquantidx
}
547 The $codeblock
\_quant\_offset()$ process shall be defined as follows:
549 \begin{pseudo
}{codeblock
\_quant\_offset}{}
550 \bsIF{\CodeblockMode==
0}
552 \bsELSEIF{using
\_ac()==
\true}
553 \bsRET{ read
\_sinta(quant
\_context\_probs())
}
555 \bsRET{read
\_sintb()
}
559 where $quant
\_context\_probs()$ shall return the context probability label set:
560 \
[\
{[\QOffsetFollow],
\QOffsetData,
\QOffsetSign\
}\
]
562 \subsubsection{Subband coefficients
}
566 This section describes the operation of the
567 $coeff
\_unpack(coeff
\_data,level,orient,quant
\_index,x,y)$ process
568 for unpacking an individual coefficient in position $(x,y)$
569 in the subband $coeff
\_data[level
][orient
]$.
571 Unpacking a coefficient shall make use of entropy decoding, inverse quantisation
572 and, in the case of DC (level
0) bands of Intra pictures, neighbourhood prediction.
574 Arithmetic coding uses a highly compact set of contexts,
575 with magnitudes contextualised on whether parent values
576 and neighbouring values are zero or non-zero. See Annex~
\ref{arithdecoding
}
577 for a definition of the Dirac arithmetic decoder.
579 The process for coefficient unpacking shall comprise up to four stages:
581 \item (for arithmetic coding only) determination of the magnitude context, based on whether the parent or neighbouring values are zero,
582 \item (for arithmetic coding only) determination of the sign context, based on the predicted sign value,
583 \item entropy decoding of the quantized coefficient value, and
584 \item inverse quantization of the quantized value.
587 The $coeff
\_unpack()$ process shall be defined as follows:
589 \begin{pseudo
}{coeff
\_unpack}{coeff
\_data,level,orient,quant
\_index,x,y
}
590 \bsIF{using
\_ac()==
\true}
591 \bsCODE{parent = zero
\_parent(coeff
\_data,level,orient, x, y)
}{\ref{zeroparent
}}
592 \bsCODE{nhood = zero
\_nhood(coeff
\_data[level
][orient
],x,y)
}{\ref{zeronhood
}}
593 \bsCODE{sign
\_pred = sign
\_predict(coeff
\_data[level
][orient
],orient,x,y)
}{\ref{signpredict
}}
594 \bsCODE{context
\_prob\_set = select
\_coeff\_ctxs(nhood, parent, sign
\_pred)
}{\ref{selectcoeffcontext
}}
595 \bsCODE{quant
\_coeff = read
\_sinta( context
\_prob\_set )
}{}
597 \bsCODE{quant
\_coeff = read
\_sintb()
}{}
599 \bsCODE{coeff
\_data[level
][orient
][y
][x
] = inverse
\_quant( quant
\_coeff, quant
\_index )
}{\ref{invquant
}}
602 \paragraph{Zero parent
}
605 The function $zero
\_parent(coeff
\_data,level,orient,v, h)$ shall return a boolean flag indicating
606 whether the parent value of a coefficient in a subband is zero. The parent coefficient
607 shall be the co-located coefficient in the parent subband, if there is one. There is deemed to be a parent if $level
\geq 2$. If a parent coefficient does not exist, $
\true$ shall be
610 Note: Levels
0 and
1 have the same number of coefficients. Thus the first level that can be used as a parent is level
1, with level
2 as its child.
612 The parent value shall be determined as follows:
614 \begin{pseudo
}{zero
\_parent}{data,level,orient,x,y
}
616 \bsCODE{parent = data
[level-
1][orient
][y//
2][x//
2]}
623 \paragraph{Zero neighbourhood
}
626 The $zero
\_nhood()$ function shall return a boolean flag indicating whether the
627 neighbouring values of a given subband coefficient are all zero.
629 The zero neighbourhood value shall be determined as follows:
631 \begin{pseudo
}{zero
\_nhood}{band,x,y
}
632 \bsIF{y>
0 \text{ and
} x>
0}
633 \bsIF{( band
[y-
1][x-
1]!=
0 \text{ or
} band
[y
][x-
1]!=
0 )
\text{ or
} band
[y-
1][x
]!=
0}
636 \bsELSEIF{y>
0 \text{ and
} x==
0}
637 \bsIF{band
[y-
1][0]!=
0}
640 \bsELSEIF{y==
0 \text{ and
} x>
0}
641 \bsIF{ band
[0][x-
1] !=
0}
648 \paragraph{Sign prediction
}
651 The $sign
\_predict()$ function shall return a prediction for the sign of the
654 Correlation within subbands depends upon orientation,
655 and so this is taken into account in forming the prediction.
657 For vertically-oriented (HL) bands, the predictor shall be the sign of the
658 coefficient above the current coefficient; for horizontally-oriented (LH)
659 bands, the predictor shall be the sign of the coefficient to the left.
661 The predictions shall be used only for the conditioning of the sign contexts.
663 The sign prediction value shall be determined as follows:
665 \begin{pseudo
}{sign
\_predict}{band,orient,x,y
}
666 \bsIF{orient==HL
\text{ and
} y==
0}
668 \bsELSEIF{orient==HL
\text{ and
} y>
0}
669 \bsRET{\sign(band
[y-
1][x
])
}
670 \bsELSEIF{orient==LH
\text{ and
} x==
0}
672 \bsELSEIF{orient==LH
\text{ and
} x>
0}
673 \bsRET{\sign(band
[y
][x-
1])
}
679 \paragraph{Coefficient context selection
}
680 \label{selectcoeffcontext
}
682 This section defines the coefficient context selection function which shall return a map
683 of context probability labels for decoding a coefficient value. Context probabilities
684 shall be as defined in Annex~
\ref{contextprobs
}.
686 The map $m$ returned shall comprise three elements, accessed by the
687 labels FOLLOW, DATA, and SIGN, where:
689 \item $m$
[FOLLOW
] is an array of labels
690 \item $m$
[DATA
] is a label
691 \item $m$
[SIGN
] is a label
694 The elements of the map returned by
695 \
[select
\_coeff\_contexts(zero
\_nhood,parent,sign
\_pred)\
]
697 shall be as defined in Table
\ref{contexttable
}, for values of
698 $zero
\_parent$, $zero
\_nhood$ and $sign
\_pred$, where the
699 context labels (e.g.
\ZPZNFollowOne,
\ZPFollowTwo,
\CoeffData and
700 \SignZero) correspond to context probabilities (i.e.
16 bit unsigned
701 integers) stored in the decoded state as defined in annex
704 The three columns on the left of table
\ref{contexttable
} represent
705 the three inputs to the coefficient context selection function. The
706 output of the function is a map with three elements. These elements
707 are accessed by the labels FOLLOW, DATA and SIGN. The values of the
708 three elements of the map are defined in the rightmost column for
712 The follow context probability sets are arrays indexed from zero as
713 per Annex~
\ref{binandcontext
}. Note also that the parent values affect the context
714 of all follow bits, and that neighbour values only affect the context of
715 the first follow bit. A common data context probability is used for all
719 Key to interpretation of the label names:
722 \item[ZP
] zero parent
723 \item[NP
] non-zero parent
724 \item[ZN
] zero neighbour
725 \item[NN
] non-zerro neighbour
726 \item[Fn
] follow bit, bin N (n+ means bin n and higher)
729 %% Table of context sets for signed coefficient extraction %%
731 \begin{tabular
}{|c|c|c|l|l|
}
733 \rowcolor[gray
]{0.75} $zero
\_parent$ & $zero
\_nhood$ & $sign
\_pred$ &
\multicolumn{2}{c|
}{\cellcolor[gray
]{0.75}\bf{Context map
}} \\
735 % Zero parent, zero neighbour, zero sign prediction
737 \true &
\true &
0 & FOLLOW &
[\ZPZNFollowOne,
\ZPFollowTwo,
\ZPFollowThree,
738 \ZPFollowFour,
\ZPFollowFive,
\ZPFollowSixPlus] \\
\cline{4-
5}
739 & & & DATA &
\CoeffData \\
\cline{4-
5}
740 & & & SIGN &
\SignZero \\
742 % Zero parent, zero neighbour, -ve sign prediction
744 \true &
\true & $<
0$ & FOLLOW &
[\ZPZNFollowOne,
\ZPFollowTwo,
\ZPFollowThree,
745 \ZPFollowFour,
\ZPFollowFive,
\ZPFollowSixPlus] \\
\cline{4-
5}
746 & & & DATA &
\CoeffData \\
\cline{4-
5}
747 & & & SIGN &
\SignNeg \\
749 % Zero parent, zero neighbour, +ve sign prediction
751 \true &
\true & $>
0$ & FOLLOW &
[\ZPZNFollowOne,
\ZPFollowTwo,
\ZPFollowThree,
752 \ZPFollowFour,
\ZPFollowFive,
\ZPFollowSixPlus] \\
\cline{4-
5}
753 & & & DATA &
\CoeffData \\
\cline{4-
5}
754 & & & SIGN &
\SignPos \\
756 % Zero parent, non-zero neighbour, zero sign prediction
758 \true &
\false &
0 & FOLLOW &
[\ZPNNFollowOne,
\ZPFollowTwo,
\ZPFollowThree,
759 \ZPFollowFour,
\ZPFollowFive,
\ZPFollowSixPlus] \\
\cline{4-
5}
760 & & & DATA &
\CoeffData \\
\cline{4-
5}
761 & & & SIGN &
\SignZero \\
763 % Zero parent, non-zero neighbour, -ve sign prediction
765 \true &
\false & $<
0$ & FOLLOW &
[\ZPNNFollowOne,
\ZPFollowTwo,
\ZPFollowThree,
766 \ZPFollowFour,
\ZPFollowFive,
\ZPFollowSixPlus] \\
\cline{4-
5}
767 & & & DATA &
\CoeffData \\
\cline{4-
5}
768 & & & SIGN &
\SignNeg \\
770 % Zero parent, non-zero neighbour, +ve sign prediction
772 \true &
\false & $>
0$ & FOLLOW &
[\ZPNNFollowOne,
\ZPFollowTwo,
\ZPFollowThree,
773 \ZPFollowFour,
\ZPFollowFive,
\ZPFollowSixPlus] \\
\cline{4-
5}
774 & & & DATA &
\CoeffData \\
\cline{4-
5}
775 & & & SIGN &
\SignPos \\
777 % Non-zero parent, zero neighbour, zero sign prediction
779 \false &
\true &
0 & FOLLOW &
[\NPZNFollowOne,
\NPFollowTwo,
\NPFollowThree,
780 \NPFollowFour,
\NPFollowFive,
\NPFollowSixPlus] \\
\cline{4-
5}
781 & & & DATA &
\CoeffData \\
\cline{4-
5}
782 & & & SIGN &
\SignZero \\
784 % Non-zero parent, zero neighbour, -ve sign prediction
786 \false &
\true & $<
0$ & FOLLOW &
[\NPZNFollowOne,
\NPFollowTwo,
\NPFollowThree,
787 \NPFollowFour,
\NPFollowFive,
\NPFollowSixPlus] \\
\cline{4-
5}
788 & & & DATA &
\CoeffData \\
\cline{4-
5}
789 & & & SIGN &
\SignNeg \\
791 % Non-zero parent, zero neighbour, +ve sign prediction
793 \false &
\true & $>
0$ & FOLLOW &
[\NPZNFollowOne,
\NPFollowTwo,
\NPFollowThree,
794 \NPFollowFour,
\NPFollowFive,
\NPFollowSixPlus] \\
\cline{4-
5}
795 & & & DATA &
\CoeffData \\
\cline{4-
5}
796 & & & SIGN &
\SignPos \\
798 % Non-zero parent, non-zero neighbour, zero sign prediction
800 \false &
\false &
0 & FOLLOW &
[\NPNNFollowOne,
\NPFollowTwo,
\NPFollowThree,
801 \NPFollowFour,
\NPFollowFive,
\NPFollowSixPlus] \\
\cline{4-
5}
802 & & & DATA &
\CoeffData \\
\cline{4-
5}
803 & & & SIGN &
\SignZero \\
805 % Zero parent, non-zero neighbour, -ve sign prediction
807 \false &
\false & $<
0$ & FOLLOW &
[\NPNNFollowOne,
\NPFollowTwo,
\NPFollowThree,
808 \NPFollowFour,
\NPFollowFive,
\NPFollowSixPlus] \\
\cline{4-
5}
809 & & & DATA &
\CoeffData \\
\cline{4-
5}
810 & & & SIGN &
\SignNeg \\
812 % Zero parent, non-zero neighbour, +ve sign prediction
814 \false &
\false & $>
0$ & FOLLOW &
[\NPNNFollowOne,
\NPFollowTwo,
\NPFollowThree,
815 \NPFollowFour,
\NPFollowFive,
\NPFollowSixPlus] \\
\cline{4-
5}
816 & & & DATA &
\CoeffData \\
\cline{4-
5}
817 & & & SIGN &
\SignPos \\
821 \caption{Subband coefficient context sets
}\label{contexttable
}
826 \subsection{Low delay wavelet coefficient unpacking
}
827 \label{lowdelayparsing
}
829 This section defines the stream syntax that shall be used for low delay profiles.
830 Only the syntax and parsing operations are defined here; picture decoding operations
831 are defined in Section~
\ref{picturedec
}.
833 In low delay operation, the Dirac syntax shall partition the wavelet coefficients into a
834 number of slices, from all subbands, corresponding to localized areas of the picture
835 \begin{comment
}(see Figure
\ref{})
\end{comment
}.
837 A slice shall meet the following requirements:
839 \item A single quantizer, weighted for each subband by a quantization matrix, shall be used for quantization of the coefficients in each slice.
840 \item All wavelet coefficients shall be entropy-coded using variable-length coding alone. Arithmetic coding shall not be used.
841 \item The number of bytes used per slice shall be the same, to within one byte, for each slice in a picture.
842 \item Each picture may change the slice parameters within the picture by setting the relevant wavelet transform parameters (Section~
\ref{sliceparams
}).
847 \item The slice structure implies that in practice incremental picture decoding can be easily achieved without accumulating an entire picture data set, yielding a decoding delay
848 proportional to the height of the slices. (The actual achievable delay may be more than one slice height due to vertical filtering delay).
849 \item Using a fixed number of bits per slice does impact on compression efficiency but
850 simplifies both encoder and decoder hardware, and assists a chain of multiple encoders
851 and decoders using the same slice parameters in producing identical coding decisions
852 and hence no cascading loss. These factors are of great significance in a
853 professional environment.
857 \subsubsection{Overall process
}
860 The low delay transform data process shall be defined as follows:
862 \begin{pseudo
}{low
\_delay\_transform\_data()
}{}
863 \bsCODE{\YTransform = initialise
\_wavelet\_data(Y)
}{\ref{wltinit
}}
864 \bsCODE{\COneTransform = initialise
\_wavelet\_data(C1)
}{\ref{wltinit
}}
865 \bsCODE{\CTwoTransform = initialise
\_wavelet\_data(C2)
}{\ref{wltinit
}}
866 \bsFOR{sy=
0}{\SlicesY-
1}
867 \bsFOR{sx=
0}{\SlicesX-
1}
868 \bsCODE{slice(sx, sy)
}{\ref{sliceparsing
}}
871 \bsCODE{intra
\_dc\_prediction(
\YTransform[0][\LL])
}{\ref{intradcprediction
}}
872 \bsCODE{intra
\_dc\_prediction(
\COneTransform[0][\LL])
}{\ref{intradcprediction
}}
873 \bsCODE{intra
\_dc\_prediction(
\CTwoTransform[0][\LL])
}{\ref{intradcprediction
}}
876 DC values at the top and left edges of a slice shall be predicted from DC values in
877 previously decoded slices, which must therefore be retained.
879 \subsubsection{Slices
}
882 This section defines the operation of the $slice(sx,sy)$ process for unpacking
883 coefficients within the slice with coordinates $(sx,sy)$.
885 Each slice shall contain the relevant coefficients from all subbands and for all
886 components. Luma data shall be unpacked rst, and shall be followed by the chroma
887 data, in which the chroma component coefficients shall be interleaved. A length code
888 shall allow the luma and chroma coefficients each to be terminated early, with remaining
889 values set to zero by means of bounded read operations.
891 The overall slice unpacking process shall be defined as follows:
893 \begin{pseudo
}{slice
}{sx,sy
}
894 \bsCODE{slice
\_bits\_left =
8*slice
\_bytes(sx,sy)
}{\ref{slicebytes
}}
895 \bsCODE{qindex=read
\_nbits(
7)
}
896 \bsCODE{slice
\_bits\_left -=
7}
897 \bsCODE{slice
\_quantisers(qindex)
}{\ref{slicequantisers
}}
898 \bsCODE{length
\_bits =
\intlog2(
8*slice
\_bytes(sx,sy)-
7)
}
899 \bsCODE{slice
\_y\_length=read
\_nbits(length
\_bits)
}
900 \bsCODE{slice
\_bits\_left -= length
\_bits}
901 \bsCODE{\ABitsLeft=slice
\_y\_length}
902 \bsCODE{luma
\_slice\_band(
0,
\LL,sx,sy)
}{\ref{lumasliceband
}}
903 \bsFOR{level=
1}{\TransformDepth}
904 \bsFOREACH{orient
}{\HL,
\LH,
\HH}
905 \bsCODE{luma
\_slice\_band(level,orient,sx,sy)
}{\ref{lumasliceband
}}
908 \bsCODE{flush
\_inputb()
}{\ref{blockreadbit
}}
909 \bsCODE{slice
\_bits\_left -= slice
\_y\_length}
910 \bsCODE{\ABitsLeft=slice
\_bits\_left}
911 \bsCODE{chroma
\_slice\_band(
0,
\LL,sx,sy)
}{\ref{chromasliceband
}}
912 \bsFOR{level=
1}{\TransformDepth}
913 \bsFOREACH{orient
}{\HL,
\LH,
\HH}
914 \bsCODE{chroma
\_slice\_band(level,orient,sx,sy)
}{\ref{chromasliceband
}}
917 \bsCODE{flush
\_inputb()
}{\ref{blockreadbit
}}
920 $slice
\_y\_length$ shall satisfy the following condition:
921 \
[slice
\_y\_length =
8*slice
\_bytes(sx, sy)-
7-length
\_bits\
]
924 Slice decoding makes use of bounded read functions, which return
1 when $
\ABitsLeft$
925 is zero. This means that remaining coefficients are set to
0, since a solitary
1 is the VLC for
0. The logic of slice decoding applies this twice in each slice: once for luma coefficients, initializing the bits left to $slice
\_y\_length$, and a second time to
926 the chroma coefficients, initializing to the number of bits remaining.
929 \subsubsection{Determining the number of bytes in a slice
}
932 The $slice
\_bytes(sx,sy)$ shall be defined as follows:
934 \begin{pseudo
}{slice
\_bytes}{sx,sy
}
935 \bsCODE{slice
\_num=sy*
\SlicesX+sx
}
936 \bsCODE{\begin{array
}{rcl
}
937 bytes & = & ((slice
\_num+
1)*
\SliceBytesNum)// \\
940 \bsCODE{\begin{array
}{rcl
}
941 bytes &-= & ((slice
\_num)*
\SliceBytesNum)// \\
948 This function produces an integer value which will on average be the ratio
949 of $
\SliceBytesNum$ to $
\SliceBytesDenom$. In many applications this ratio
950 will not be an integer number, and the number of bytes will vary from
951 slice to slice by one byte from time to time. This allows the low delay
952 syntax to support any compression ratio exactly.
955 \subsubsection{Setting slice quantisers
}
956 \label{slicequantisers
}
958 This section defines how quantisers for individual subbands are
959 determined from the quantisation matrix and the quantisation index.
960 The $slice
\_quantisers()$ function shall be defined as follows:
962 \begin{pseudo
}{slice
\_quantisers}{qindex
}
963 \bsCODE{\Quant[0][\LL]=
\max(qindex-
\QuantMatrix[0][\LL],
0)
}
964 \bsFOR{level=
1}{\TransformDepth}
965 \bsFOREACH{orient
}{HL, LH, HH
}
966 \bsCODE{qval=
\max(qindex-
\QuantMatrix[level
][orient
],
0)
}
967 \bsCODE{\Quant[level
][orient
]=qval
}
973 The non-negative quantisation matrix values are subtracted from the slice
974 quantiser value, and so a higher value in the quantisation matrix represents
975 a lower quantisation index and thus a lower degree of quantisation. The
976 quantisation index value is also clipped to
0 so that it is non-negative.
977 This ensures that as many subbands as possible within the slice can be
978 coded losslessly. The quantisation matrix values are set as part of decoding
979 the transform parameters (Section~
\ref{quantmatrix
}).
982 \subsubsection{Slice subbands
}
985 This section defines the operation of the $luma
\_slice\_band( level,orient,sx,sy)$ for
986 unpacking individual luma slice subbands, and $chroma
\_slice\_band( level,orient,sx,sy)$. for
987 unpacking individual chroma slice subbands.
989 \paragraph{Slice subband dimensions
}
990 $\ $
\newline\label{slicedimensions
}
991 The rectangular set of coefficients covered by a slice component ($Y$, $C1$ and $C2$)
992 is demarcated by the values $slice
\_left, slice
\_right, slice
\_top, slice
\_bottom$, defined as fractions
993 of the subband dimensions (Section~
\ref{subbandwidthheight
}) by the following functions:
995 slice
\_left(sx,level,c) & = & (subband
\_width(level,c)*sx)//
\SlicesX \\
996 slice
\_right(sx,level,c) & = & (subband
\_width(level,c)*(sx+
1))//
\SlicesX \\
997 slice
\_top(sy,level,c) & = & (subband
\_height(level,c)*sy)//
\SlicesY \\
998 slice
\_bottom(sy,level,c) & = & (subband
\_height(level,c)*(sy+
1))//
\SlicesY
1001 where $c=Y$ for luma coefficients, and $C1$ or $C2$ for chroma coefficients.
1005 \item The slice subband area formulae correspond to the codeblock area
1006 formulae for the core syntax (Section~
\ref{codeblockdimensions
}).
1007 \item Slice subbands may change dimension by
1 from one slice to another
1008 if $
\SlicesX$ or $
\SlicesY$ do not divide the horizontal or vertical dimensions
1010 \item Chroma slice subbands might not have exactly the scaled dimensions of
1011 the luma slice subband, since the $
\SlicesX$ and $SlicesY$ values may exactly
1012 divide luma dimensions but not chroma dimensions; and chroma components
1013 may receive different padding, depending on the transform depth.
1014 \item These issues may be easily avoided in particular applications by choosing
1015 suitable values for the transform depth and $
\SlicesX$ and $SlicesY$.
1019 \paragraph{Luma slice subband data
}
1020 \label{lumasliceband
}
1022 The process for unpacking luma slice coefficients shall be defined as follows:
1024 \begin{pseudo
}{luma
\_slice\_band}{level, orient, sx, sy
}
1025 \bsFOR{y=slice
\_top(sy,level,Y)
}{slice
\_bottom(sy,level,Y)-
1}{\ref{slicedimensions
}}
1026 \bsFOR{x=slice
\_left(sx,level,Y)
}{slice
\_right(sx,level,Y)-
1}{\ref{slicedimensions
}}
1027 \bsITEM{val
}{sintb
}{\ref{segol
}}
1028 \bsCODE{q=
\Quant[Y
][level
][orient
]}
1029 \bsCODE{\YTransform[level
][orient
][y
][x
]=inverse
\_quant(val,q)
}
1034 \paragraph{Chroma slice subband data
}
1035 \label{chromasliceband
}
1037 Chroma slice subband coefficients shall follow luma coefficients within each slice.
1038 The two chroma components shall be interleaved coefficient-by-coefficient. The
1039 process for unpacking chroma slice coefficients shall be defined as
1042 \begin{pseudo
}{luma
\_slice\_band}{level, orient, sx, sy
}
1043 \bsFOR{y=slice
\_top(sy,level,C1)
}{slice
\_bottom(sy,level,C1)-
1}{\ref{slicedimensions
}}
1044 \bsFOR{x=slice
\_left(sx,level,C1)
}{slice
\_right(sx,level,C1)-
1}{\ref{slicedimensions
}}
1045 \bsCODE{q=
\Quant[level
][orient
]}
1046 \bsITEM{val
}{sintb
}{\ref{segol
}}
1047 \bsCODE{\COneTransform[level
][orient
]=inverse
\_quant(val,q)
}{\ref{invquant
}}
1048 \bsITEM{val
}{sintb
}{\ref{segol
}}
1049 \bsCODE{\CTwoTransform[level
][orient
]=inverse
\_quant(val,q2)
}{\ref{invquant
}}
1055 \begin{informative*
}
1056 \subsection{Data adaption and application requirements
}