Browse code

Dirac: Doxygen comments and some formatting enhancements

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Jordi Ortiz authored on 2011/10/21 03:18:50
Showing 3 changed files
... ...
@@ -1,6 +1,7 @@
1 1
 /*
2 2
  * Copyright (C) 2007 Marco Gerards <marco@gnu.org>
3 3
  * Copyright (C) 2009 David Conrad
4
+ * Copyright (C) 2011 Jordi Ortiz
4 5
  *
5 6
  * This file is part of FFmpeg.
6 7
  *
... ...
@@ -22,7 +23,7 @@
22 22
 /**
23 23
  * @file
24 24
  * Dirac Decoder
25
- * @author Marco Gerards <marco@gnu.org>
25
+ * @author Marco Gerards <marco@gnu.org>, David Conrad, Jordi Ortiz <nenjordi@gmail.com>
26 26
  */
27 27
 
28 28
 #include "libavutil/imgutils.h"
... ...
@@ -31,7 +32,7 @@
31 31
 #include "golomb.h"
32 32
 #include "mpeg12data.h"
33 33
 
34
-// defaults for source parameters
34
+/* defaults for source parameters */
35 35
 static const dirac_source_params dirac_source_parameters_defaults[] = {
36 36
     { 640,  480,  2, 0, 0, 1,  1, 640,  480,  0, 0, 1, 0 },
37 37
     { 176,  120,  2, 0, 0, 9,  2, 176,  120,  0, 0, 1, 1 },
... ...
@@ -42,7 +43,6 @@ static const dirac_source_params dirac_source_parameters_defaults[] = {
42 42
     { 704,  576,  2, 0, 1, 10, 3, 704,  576,  0, 0, 1, 2 },
43 43
     { 720,  480,  1, 1, 0, 4,  2, 704,  480,  8, 0, 3, 1 },
44 44
     { 720,  576,  1, 1, 1, 3,  3, 704,  576,  8, 0, 3, 2 },
45
-
46 45
     { 1280, 720,  1, 0, 1, 7,  1, 1280, 720,  0, 0, 3, 3 },
47 46
     { 1280, 720,  1, 0, 1, 6,  1, 1280, 720,  0, 0, 3, 3 },
48 47
     { 1920, 1080, 1, 1, 1, 4,  1, 1920, 1080, 0, 0, 3, 3 },
... ...
@@ -51,14 +51,16 @@ static const dirac_source_params dirac_source_parameters_defaults[] = {
51 51
     { 1920, 1080, 1, 0, 1, 6,  1, 1920, 1080, 0, 0, 3, 3 },
52 52
     { 2048, 1080, 0, 0, 1, 2,  1, 2048, 1080, 0, 0, 4, 4 },
53 53
     { 4096, 2160, 0, 0, 1, 2,  1, 4096, 2160, 0, 0, 4, 4 },
54
-
55 54
     { 3840, 2160, 1, 0, 1, 7,  1, 3840, 2160, 0, 0, 3, 3 },
56 55
     { 3840, 2160, 1, 0, 1, 6,  1, 3840, 2160, 0, 0, 3, 3 },
57 56
     { 7680, 4320, 1, 0, 1, 7,  1, 3840, 2160, 0, 0, 3, 3 },
58 57
     { 7680, 4320, 1, 0, 1, 6,  1, 3840, 2160, 0, 0, 3, 3 },
59 58
 };
60 59
 
61
-//[DIRAC_STD] Table 10.4 Available preset pixel aspect ratio values
60
+/**
61
+ * Dirac Specification ->
62
+ * Table 10.4 - Available preset pixel aspect ratio values
63
+ */
62 64
 static const AVRational dirac_preset_aspect_ratios[] = {
63 65
     {1, 1},
64 66
     {10, 11},
... ...
@@ -68,13 +70,19 @@ static const AVRational dirac_preset_aspect_ratios[] = {
68 68
     {4, 3},
69 69
 };
70 70
 
71
-//[DIRAC_STD] Values 9,10 of 10.3.5 Frame Rate. Table 10.3 Available preset frame rate values
71
+/**
72
+ * Dirac Specification ->
73
+ * Values 9,10 of 10.3.5 Frame Rate. Table 10.3 Available preset frame rate values
74
+ */
72 75
 static const AVRational dirac_frame_rate[] = {
73 76
     {15000, 1001},
74 77
     {25, 2},
75 78
 };
76 79
 
77
-//[DIRAC_STD] This should be equivalent to Table 10.5 Available signal range presets
80
+/**
81
+ * Dirac Specification ->
82
+ * This should be equivalent to Table 10.5 Available signal range presets
83
+ */
78 84
 static const struct {
79 85
     uint8_t             bitdepth;
80 86
     enum AVColorRange   color_range;
... ...
@@ -103,13 +111,19 @@ static const struct {
103 103
     { AVCOL_PRI_BT709,     AVCOL_SPC_BT709,   AVCOL_TRC_UNSPECIFIED /* DCinema */ },
104 104
 };
105 105
 
106
-//[DIRAC_STD] Table 10.2 Supported chroma sampling formats + Luma Offset
106
+/**
107
+ * Dirac Specification ->
108
+ * Table 10.2 Supported chroma sampling formats + Luma Offset
109
+ */
107 110
 static const enum PixelFormat dirac_pix_fmt[2][3] = {
108 111
     { PIX_FMT_YUV444P,  PIX_FMT_YUV422P,  PIX_FMT_YUV420P  },
109 112
     { PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P },
110 113
 };
111 114
 
112
-// [DIRAC_STD] 10.3 Parse Source Parameters. source_parameters(base_video_format)
115
+/**
116
+ * Dirac Specification ->
117
+ * 10.3 Parse Source Parameters. source_parameters(base_video_format)
118
+ */
113 119
 static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
114 120
                                    dirac_source_params *source)
115 121
 {
... ...
@@ -117,51 +131,52 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
117 117
     unsigned luma_depth = 8, luma_offset = 16;
118 118
     int idx;
119 119
 
120
-    //[DIRAC_STD] 10.3.2 Frame size. frame_size(video_params)
121
-    if (get_bits1(gb)) {   //[DIRAC_STD] custom_dimensions_flag
122
-      source->width  = svq3_get_ue_golomb(gb); //[DIRAC_STD] FRAME_WIDTH
123
-      source->height = svq3_get_ue_golomb(gb); //[DIRAC_STD] FRAME_HEIGHT
120
+    /* [DIRAC_STD] 10.3.2 Frame size. frame_size(video_params) */
121
+    if (get_bits1(gb)) {                         /* [DIRAC_STD] custom_dimensions_flag */
122
+        source->width  = svq3_get_ue_golomb(gb); /* [DIRAC_STD] FRAME_WIDTH            */
123
+        source->height = svq3_get_ue_golomb(gb); /* [DIRAC_STD] FRAME_HEIGHT           */
124 124
     }
125 125
 
126
-    //[DIRAC_STD] 10.3.3 Chroma Sampling Format. chroma_sampling_format(video_params)
127
-    if (get_bits1(gb)) //[DIRAC_STD] custom_chroma_format_flag
128
-      source->chroma_format = svq3_get_ue_golomb(gb); //[DIRAC_STD] CHROMA_FORMAT_INDEX
126
+    /* [DIRAC_STD] 10.3.3 Chroma Sampling Format.
127
+       chroma_sampling_format(video_params) */
128
+    if (get_bits1(gb))                                  /* [DIRAC_STD] custom_chroma_format_flag */
129
+        source->chroma_format = svq3_get_ue_golomb(gb); /*[DIRAC_STD] CHROMA_FORMAT_INDEX        */
129 130
     if (source->chroma_format > 2U) {
130 131
         av_log(avctx, AV_LOG_ERROR, "Unknown chroma format %d\n",
131 132
                source->chroma_format);
132 133
         return -1;
133 134
     }
134 135
 
135
-    //[DIRAC_STD] 10.3.4 Scan Format. scan_format(video_params)
136
-    if (get_bits1(gb)) //[DIRAC_STD] custom_scan_format_flag
137
-      source->interlaced = svq3_get_ue_golomb(gb); //[DIRAC_STD] SOURCE_SAMPLING
136
+    /* [DIRAC_STD] 10.3.4 Scan Format. scan_format(video_params) */
137
+    if (get_bits1(gb))                               /* [DIRAC_STD] custom_scan_format_flag */
138
+        source->interlaced = svq3_get_ue_golomb(gb); /* [DIRAC_STD] SOURCE_SAMPLING         */
138 139
     if (source->interlaced > 1U)
139 140
         return -1;
140 141
 
141
-    //[DIRAC_STD] 10.3.5 Frame Rate. frame_rate(video_params)
142
-    if (get_bits1(gb)) { //[DIRAC_STD] custom_frame_rate_flag
143
-      source->frame_rate_index = svq3_get_ue_golomb(gb);
142
+    /* [DIRAC_STD] 10.3.5 Frame Rate. frame_rate(video_params) */
143
+    if (get_bits1(gb)) { /* [DIRAC_STD] custom_frame_rate_flag */
144
+        source->frame_rate_index = svq3_get_ue_golomb(gb);
144 145
 
145 146
         if (source->frame_rate_index > 10U)
146 147
             return -1;
147 148
 
148
-        if (!source->frame_rate_index) {
149
-          frame_rate.num = svq3_get_ue_golomb(gb); //[DIRAC_STD] FRAME_RATE_NUMER
150
-          frame_rate.den = svq3_get_ue_golomb(gb); //[DIRAC_STD] FRAME_RATE_DENOM
149
+        if (!source->frame_rate_index){
150
+            frame_rate.num = svq3_get_ue_golomb(gb); /* [DIRAC_STD] FRAME_RATE_NUMER */
151
+            frame_rate.den = svq3_get_ue_golomb(gb); /* [DIRAC_STD] FRAME_RATE_DENOM */
151 152
         }
152 153
     }
153
-    if (source->frame_rate_index > 0) { //[DIRAC_STD] preset_frame_rate(video_params,index)
154
+    if (source->frame_rate_index > 0) { /* [DIRAC_STD] preset_frame_rate(video_params,index) */
154 155
         if (source->frame_rate_index <= 8)
155
-            frame_rate = avpriv_frame_rate_tab[source->frame_rate_index]; //[DIRAC_STD] Table 10.3 values 1-8
156
+            frame_rate = avpriv_frame_rate_tab[source->frame_rate_index];  /* [DIRAC_STD] Table 10.3 values 1-8  */
156 157
         else
157
-          frame_rate = dirac_frame_rate[source->frame_rate_index-9]; //[DIRAC_STD] Table 10.3 values 9-10
158
+            frame_rate = dirac_frame_rate[source->frame_rate_index-9]; /* [DIRAC_STD] Table 10.3 values 9-10 */
158 159
     }
159 160
     av_reduce(&avctx->time_base.num, &avctx->time_base.den,
160 161
               frame_rate.den, frame_rate.num, 1<<30);
161 162
 
162
-    //[DIRAC_STD] 10.3.6 Pixel Aspect Ratio. pixel_aspect_ratio(video_params)
163
-    if (get_bits1(gb)) { //[DIRAC_STD] custom_pixel_aspect_ratio_flag
164
-      source->aspect_ratio_index = svq3_get_ue_golomb(gb); //[DIRAC_STD] index
163
+    /* [DIRAC_STD] 10.3.6 Pixel Aspect Ratio. pixel_aspect_ratio(video_params) */
164
+    if (get_bits1(gb)) { /* [DIRAC_STD] custom_pixel_aspect_ratio_flag */
165
+        source->aspect_ratio_index = svq3_get_ue_golomb(gb); /* [DIRAC_STD] index */
165 166
 
166 167
         if (source->aspect_ratio_index > 6U)
167 168
             return -1;
... ...
@@ -171,37 +186,37 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
171 171
             avctx->sample_aspect_ratio.den = svq3_get_ue_golomb(gb);
172 172
         }
173 173
     }
174
-    if (source->aspect_ratio_index > 0) //[DIRAC_STD] Take value from Table 10.4 Available preset pixel aspect ratio values
174
+    if (source->aspect_ratio_index > 0) /* [DIRAC_STD] Take value from Table 10.4 Available preset pixel aspect ratio values */
175 175
         avctx->sample_aspect_ratio =
176
-                dirac_preset_aspect_ratios[source->aspect_ratio_index-1];
177
-
178
-    //[DIRAC_STD] 10.3.7 Clean area. clean_area(video_params)
179
-    if (get_bits1(gb)) { //[DIRAC_STD] custom_clean_area_flag
180
-      source->clean_width        = svq3_get_ue_golomb(gb); //[DIRAC_STD] CLEAN_WIDTH
181
-      source->clean_height       = svq3_get_ue_golomb(gb); //[DIRAC_STD] CLEAN_HEIGHT
182
-      source->clean_left_offset  = svq3_get_ue_golomb(gb); //[DIRAC_STD] CLEAN_LEFT_OFFSET
183
-      source->clean_right_offset = svq3_get_ue_golomb(gb); //[DIRAC_STD] CLEAN_RIGHT_OFFSET
176
+            dirac_preset_aspect_ratios[source->aspect_ratio_index-1];
177
+
178
+    /* [DIRAC_STD] 10.3.7 Clean area. clean_area(video_params) */
179
+    if (get_bits1(gb)) { /* [DIRAC_STD] custom_clean_area_flag */
180
+        source->clean_width        = svq3_get_ue_golomb(gb); /* [DIRAC_STD] CLEAN_WIDTH        */
181
+        source->clean_height       = svq3_get_ue_golomb(gb); /* [DIRAC_STD] CLEAN_HEIGHT       */
182
+        source->clean_left_offset  = svq3_get_ue_golomb(gb); /* [DIRAC_STD] CLEAN_LEFT_OFFSET  */
183
+        source->clean_right_offset = svq3_get_ue_golomb(gb); /* [DIRAC_STD] CLEAN_RIGHT_OFFSET */
184 184
     }
185 185
 
186
-    //[DIRAC_STD] 10.3.8 Signal range. signal_range(video_params)
187
-    //[DIRAC_STD] WARNING: Some adaptation seemed to be done using the AVCOL_RANGE_MPEG/JPEG values
188
-    if (get_bits1(gb)) { //[DIRAC_STD] custom_signal_range_flag
189
-      source->pixel_range_index = svq3_get_ue_golomb(gb); //[DIRAC_STD] index
186
+    /*[DIRAC_STD] 10.3.8 Signal range. signal_range(video_params)
187
+      WARNING: Some adaptation seemed to be done using the AVCOL_RANGE_MPEG/JPEG values */
188
+    if (get_bits1(gb)) {                                    /*[DIRAC_STD] custom_signal_range_flag */
189
+        source->pixel_range_index = svq3_get_ue_golomb(gb); /*[DIRAC_STD] index */
190 190
 
191 191
         if (source->pixel_range_index > 4U)
192 192
             return -1;
193 193
 
194
-        // This assumes either fullrange or MPEG levels only
194
+        /* This assumes either fullrange or MPEG levels only */
195 195
         if (!source->pixel_range_index) {
196 196
             luma_offset = svq3_get_ue_golomb(gb);
197 197
             luma_depth  = av_log2(svq3_get_ue_golomb(gb))+1;
198
-            svq3_get_ue_golomb(gb); // chroma offset //@Jordi: Why are these two ignored?
199
-            svq3_get_ue_golomb(gb); // chroma excursion
198
+            svq3_get_ue_golomb(gb); /* chroma offset @Jordi: Why are these two ignored? */
199
+            svq3_get_ue_golomb(gb); /* chroma excursion */
200 200
 
201 201
             avctx->color_range = luma_offset ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
202 202
         }
203 203
     }
204
-    if (source->pixel_range_index > 0) { //[DIRAC_STD] Take values from Table 10.5 Available signal range presets
204
+    if (source->pixel_range_index > 0) { /*[DIRAC_STD] Take values from Table 10.5 Available signal range presets */
205 205
         idx                = source->pixel_range_index-1;
206 206
         luma_depth         = pixel_range_presets[idx].bitdepth;
207 207
         avctx->color_range = pixel_range_presets[idx].color_range;
... ...
@@ -212,9 +227,9 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
212 212
 
213 213
     avctx->pix_fmt = dirac_pix_fmt[!luma_offset][source->chroma_format];
214 214
 
215
-    //[DIRAC_STD] 10.3.9 Colour specification. colour_spec(video_params)
216
-    if (get_bits1(gb)) { //[DIRAC_STD] custom_colour_spec_flag
217
-      idx = source->color_spec_index = svq3_get_ue_golomb(gb); //[DIRAC_STD] index
215
+    /* [DIRAC_STD] 10.3.9 Colour specification. colour_spec(video_params) */
216
+    if (get_bits1(gb)) { /* [DIRAC_STD] custom_colour_spec_flag */
217
+        idx = source->color_spec_index = svq3_get_ue_golomb(gb); /* [DIRAC_STD] index */
218 218
 
219 219
         if (source->color_spec_index > 4U)
220 220
             return -1;
... ...
@@ -224,13 +239,13 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
224 224
         avctx->color_trc       = dirac_color_presets[idx].color_trc;
225 225
 
226 226
         if (!source->color_spec_index) {
227
-          //[DIRAC_STD] 10.3.9.1 Color primaries
227
+            /* [DIRAC_STD] 10.3.9.1 Color primaries */
228 228
             if (get_bits1(gb)) {
229 229
                 idx = svq3_get_ue_golomb(gb);
230 230
                 if (idx < 3U)
231 231
                     avctx->color_primaries = dirac_primaries[idx];
232 232
             }
233
-            //[DIRAC_STD] 10.3.9.2 Color matrix
233
+            /* [DIRAC_STD] 10.3.9.2 Color matrix */
234 234
             if (get_bits1(gb)) {
235 235
                 idx = svq3_get_ue_golomb(gb);
236 236
                 if (!idx)
... ...
@@ -238,7 +253,7 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
238 238
                 else if (idx == 1)
239 239
                     avctx->colorspace = AVCOL_SPC_BT470BG;
240 240
             }
241
-            //[DIRAC_STD] 10.3.9.3 Transfer function
241
+            /* [DIRAC_STD] 10.3.9.3 Transfer function */
242 242
             if (get_bits1(gb) && !svq3_get_ue_golomb(gb))
243 243
                 avctx->color_trc = AVCOL_TRC_BT709;
244 244
         }
... ...
@@ -252,20 +267,23 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
252 252
     return 0;
253 253
 }
254 254
 
255
-//[DIRAC_SPEC] 10. Sequence Header. sequence_header()
255
+/**
256
+ * Dirac Specification ->
257
+ *  10. Sequence Header. sequence_header()
258
+ */
256 259
 int avpriv_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb,
257 260
                                    dirac_source_params *source)
258 261
 {
259 262
     unsigned version_major;
260 263
     unsigned video_format, picture_coding_mode;
261 264
 
262
-    //[DIRAC_SPEC] 10.1 Parse Parameters. parse_parameters()
265
+    /* [DIRAC_SPEC] 10.1 Parse Parameters. parse_parameters() */
263 266
     version_major  = svq3_get_ue_golomb(gb);
264 267
     svq3_get_ue_golomb(gb); /* version_minor */
265 268
     avctx->profile = svq3_get_ue_golomb(gb);
266 269
     avctx->level   = svq3_get_ue_golomb(gb);
267
-    //[DIRAC_SPEC] sequence_header() -> base_video_format as defined in...
268
-    // ... 10.2 Base Video Format, table 10.1 Dirac predefined video formats
270
+    /* [DIRAC_SPEC] sequence_header() -> base_video_format as defined in
271
+       10.2 Base Video Format, table 10.1 Dirac predefined video formats */
269 272
     video_format   = svq3_get_ue_golomb(gb);
270 273
 
271 274
     if (version_major < 2)
... ...
@@ -276,11 +294,11 @@ int avpriv_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb,
276 276
     if (video_format > 20U)
277 277
         return -1;
278 278
 
279
-    // Fill in defaults for the source parameters.
279
+    /* Fill in defaults for the source parameters. */
280 280
     *source = dirac_source_parameters_defaults[video_format];
281 281
 
282
-    //[DIRAC_STD] 10.3 Source Parameters
283
-    // Override the defaults.
282
+    /*[DIRAC_STD] 10.3 Source Parameters
283
+      Override the defaults. */
284 284
     if (parse_source_parameters(avctx, gb, source))
285 285
         return -1;
286 286
 
... ...
@@ -289,8 +307,8 @@ int avpriv_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb,
289 289
 
290 290
     avcodec_set_dimensions(avctx, source->width, source->height);
291 291
 
292
-    //[DIRAC_STD] picture_coding_mode shall be 0 for fields and 1 for frames
293
-    // currently only used to signal field coding
292
+    /*[DIRAC_STD] picture_coding_mode shall be 0 for fields and 1 for frames
293
+      currently only used to signal field coding */
294 294
     picture_coding_mode = svq3_get_ue_golomb(gb);
295 295
     if (picture_coding_mode != 0) {
296 296
         av_log(avctx, AV_LOG_ERROR, "Unsupported picture coding mode %d",
... ...
@@ -1,6 +1,7 @@
1 1
 /*
2 2
  * Copyright (C) 2007 Marco Gerards <marco@gnu.org>
3 3
  * Copyright (C) 2009 David Conrad
4
+ * Copyright (C) 2011 Jordi Ortiz
4 5
  *
5 6
  * This file is part of FFmpeg.
6 7
  *
... ...
@@ -26,6 +27,8 @@
26 26
  * @file
27 27
  * Interface to Dirac Decoder/Encoder
28 28
  * @author Marco Gerards <marco@gnu.org>
29
+ * @author David Conrad
30
+ * @author Jordi Ortiz
29 31
  */
30 32
 
31 33
 #include "avcodec.h"
... ...
@@ -1,6 +1,7 @@
1 1
 /*
2 2
  * Copyright (C) 2007 Marco Gerards <marco@gnu.org>
3 3
  * Copyright (C) 2009 David Conrad
4
+ * Copyright (C) 2011 Jordi Ortiz
4 5
  *
5 6
  * This file is part of FFmpeg.
6 7
  *
... ...
@@ -22,7 +23,7 @@
22 22
 /**
23 23
  * @file libavcodec/diracdec.c
24 24
  * Dirac Decoder
25
- * @author Marco Gerards <marco@gnu.org>
25
+ * @author Marco Gerards <marco@gnu.org>, David Conrad, Jordi Ortiz <nenjordi@gmail.com>
26 26
  */
27 27
 
28 28
 #include "avcodec.h"
... ...
@@ -53,10 +54,10 @@
53 53
  * The spec limits this to 3 for frame coding, but in practice can be as high as 6
54 54
  */
55 55
 #define MAX_REFERENCE_FRAMES 8
56
-#define MAX_DELAY 5         ///< limit for main profile for frame coding (TODO: field coding)
56
+#define MAX_DELAY 5         /* limit for main profile for frame coding (TODO: field coding) */
57 57
 #define MAX_FRAMES (MAX_REFERENCE_FRAMES + MAX_DELAY + 1)
58
-#define MAX_QUANT 68        ///< max quant for VC-2
59
-#define MAX_BLOCKSIZE 32    ///< maximum xblen/yblen we support
58
+#define MAX_QUANT 68        /* max quant for VC-2 */
59
+#define MAX_BLOCKSIZE 32    /* maximum xblen/yblen we support */
60 60
 
61 61
 /**
62 62
  * DiracBlock->ref flags, if set then the block does MC from the given ref
... ...
@@ -71,7 +72,7 @@
71 71
  */
72 72
 #define DELAYED_PIC_REF 4
73 73
 
74
-#define ff_emulated_edge_mc ff_emulated_edge_mc_8 //Fix: change the calls to this function regarding bit depth
74
+#define ff_emulated_edge_mc ff_emulated_edge_mc_8 /* Fix: change the calls to this function regarding bit depth */
75 75
 
76 76
 #define CALC_PADDING(size, depth) \
77 77
          (((size + (1 << depth) - 1) >> depth) << depth)
... ...
@@ -79,10 +80,9 @@
79 79
 #define DIVRNDUP(a, b) (((a) + (b) - 1) / (b))
80 80
 
81 81
 typedef struct {
82
-  //FF_COMMON_FRAME
83 82
   AVFrame avframe;
84 83
 
85
-  int interpolated[3];    ///< 1 if hpel[] is valid
84
+    int interpolated[3];    /* 1 if hpel[] is valid */
86 85
   uint8_t *hpel[3][4];
87 86
   uint8_t *hpel_base[3][4];
88 87
 } DiracFrame;
... ...
@@ -91,7 +91,7 @@ typedef struct {
91 91
     union {
92 92
         int16_t mv[2][2];
93 93
         int16_t dc[3];
94
-    } u; // anonymous unions aren't in C99 :(
94
+    } u; /* anonymous unions aren't in C99 :( */
95 95
     uint8_t ref;
96 96
 } DiracBlock;
97 97
 
... ...
@@ -105,7 +105,7 @@ typedef struct SubBand {
105 105
     IDWTELEM *ibuf;
106 106
     struct SubBand *parent;
107 107
 
108
-    // for low delay
108
+    /* for low delay */
109 109
     unsigned length;
110 110
     const uint8_t *coeff_data;
111 111
 } SubBand;
... ...
@@ -122,13 +122,13 @@ typedef struct Plane {
122 122
     IDWTELEM *idwt_buf_base;
123 123
     IDWTELEM *idwt_tmp;
124 124
 
125
-    // block length
125
+    /* block length */
126 126
     uint8_t xblen;
127 127
     uint8_t yblen;
128
-    // block separation (block n+1 starts after this many pixels in block n)
128
+    /* block separation (block n+1 starts after this many pixels in block n) */
129 129
     uint8_t xbsep;
130 130
     uint8_t ybsep;
131
-    // amount of overspill on each edge (half of the overlap between blocks)
131
+    /* amount of overspill on each edge (half of the overlap between blocks) */
132 132
     uint8_t xoffset;
133 133
     uint8_t yoffset;
134 134
 
... ...
@@ -142,19 +142,19 @@ typedef struct DiracContext {
142 142
     GetBitContext gb;
143 143
     dirac_source_params source;
144 144
     int seen_sequence_header;
145
-    int frame_number;           ///< number of the next frame to display
145
+    int frame_number;           /* number of the next frame to display       */
146 146
     Plane plane[3];
147 147
     int chroma_x_shift;
148 148
     int chroma_y_shift;
149 149
 
150
-    int zero_res;               ///< zero residue flag
151
-    int is_arith;               ///< whether coeffs use arith or golomb coding
152
-    int low_delay;              ///< use the low delay syntax
153
-    int globalmc_flag;          ///< use global motion compensation
154
-    int num_refs;               ///< number of reference pictures
150
+    int zero_res;               /* zero residue flag                         */
151
+    int is_arith;               /* whether coeffs use arith or golomb coding */
152
+    int low_delay;              /* use the low delay syntax                  */
153
+    int globalmc_flag;          /* use global motion compensation            */
154
+    int num_refs;               /* number of reference pictures              */
155 155
 
156
-    // wavelet decoding
157
-    unsigned wavelet_depth;     ///< depth of the IDWT
156
+    /* wavelet decoding */
157
+    unsigned wavelet_depth;     /* depth of the IDWT                         */
158 158
     unsigned wavelet_idx;
159 159
 
160 160
     /**
... ...
@@ -170,29 +170,29 @@ typedef struct DiracContext {
170 170
     } codeblock[MAX_DWT_LEVELS+1];
171 171
 
172 172
     struct {
173
-        unsigned num_x;         ///< number of horizontal slices
174
-        unsigned num_y;         ///< number of vertical slices
175
-        AVRational bytes;       ///< average bytes per slice
176
-      uint8_t quant[MAX_DWT_LEVELS][4]; //[DIRAC_STD] E.1
173
+        unsigned num_x;         /* number of horizontal slices               */
174
+        unsigned num_y;         /* number of vertical slices                 */
175
+        AVRational bytes;       /* average bytes per slice                   */
176
+        uint8_t quant[MAX_DWT_LEVELS][4]; /* [DIRAC_STD] E.1 */
177 177
     } lowdelay;
178 178
 
179 179
     struct {
180
-        int pan_tilt[2];        ///< pan/tilt vector
181
-        int zrs[2][2];          ///< zoom/rotate/shear matrix
182
-        int perspective[2];     ///< perspective vector
180
+        int pan_tilt[2];        /* pan/tilt vector                           */
181
+        int zrs[2][2];          /* zoom/rotate/shear matrix                  */
182
+        int perspective[2];     /* perspective vector                        */
183 183
         unsigned zrs_exp;
184 184
         unsigned perspective_exp;
185 185
     } globalmc[2];
186 186
 
187
-    // motion compensation
188
-  uint8_t mv_precision; //[DIRAC_STD] REFS_WT_PRECISION
189
-  int16_t weight[2]; ////[DIRAC_STD] REF1_WT and REF2_WT
190
-  unsigned weight_log2denom; ////[DIRAC_STD] REFS_WT_PRECISION
187
+    /* motion compensation */
188
+    uint8_t mv_precision;       /* [DIRAC_STD] REFS_WT_PRECISION             */
189
+    int16_t weight[2];          /* [DIRAC_STD] REF1_WT and REF2_WT           */
190
+    unsigned weight_log2denom;  /* [DIRAC_STD] REFS_WT_PRECISION             */
191 191
 
192
-    int blwidth;            ///< number of blocks (horizontally)
193
-    int blheight;           ///< number of blocks (vertically)
194
-    int sbwidth;            ///< number of superblocks (horizontally)
195
-    int sbheight;           ///< number of superblocks (vertically)
192
+    int blwidth;                /* number of blocks (horizontally)           */
193
+    int blheight;               /* number of blocks (vertically)             */
194
+    int sbwidth;                /* number of superblocks (horizontally)      */
195
+    int sbheight;               /* number of superblocks (vertically)        */
196 196
 
197 197
     uint8_t *sbsplit;
198 198
     DiracBlock *blmotion;
... ...
@@ -200,7 +200,7 @@ typedef struct DiracContext {
200 200
     uint8_t *edge_emu_buffer[4];
201 201
     uint8_t *edge_emu_buffer_base;
202 202
 
203
-    uint16_t *mctmp;        ///< buffer holding the MC data multipled by OBMC weights
203
+    uint16_t *mctmp;            /* buffer holding the MC data multipled by OBMC weights */
204 204
     uint8_t *mcscratch;
205 205
 
206 206
     DECLARE_ALIGNED(16, uint8_t, obmc_weight)[3][MAX_BLOCKSIZE*MAX_BLOCKSIZE];
... ...
@@ -219,7 +219,10 @@ typedef struct DiracContext {
219 219
     DiracFrame all_frames[MAX_FRAMES];
220 220
 } DiracContext;
221 221
 
222
-// [DIRAC_STD] Parse code values. 9.6.1 Table 9.1
222
+/**
223
+ * Dirac Specification ->
224
+ * Parse code values. 9.6.1 Table 9.1
225
+ */
223 226
 enum dirac_parse_code {
224 227
     pc_seq_header         = 0x00,
225 228
     pc_eos                = 0x10,
... ...
@@ -277,7 +280,7 @@ static const int qoffset_inter_tab[MAX_QUANT+1] = {
277 277
     24576, 29226
278 278
 };
279 279
 
280
-// magic number division by 3 from schroedinger
280
+/* magic number division by 3 from schroedinger */
281 281
 static inline int divide3(int x)
282 282
 {
283 283
     return ((x+1)*21845 + 10922) >> 16;
... ...
@@ -318,20 +321,20 @@ static int alloc_sequence_buffers(DiracContext *s)
318 318
     int sbheight = DIVRNDUP(s->source.height, 4);
319 319
     int i, w, h, top_padding;
320 320
 
321
-    // todo: think more about this / use or set Plane here
321
+    /* todo: think more about this / use or set Plane here */
322 322
     for (i = 0; i < 3; i++) {
323 323
         int max_xblen = MAX_BLOCKSIZE >> (i ? s->chroma_x_shift : 0);
324 324
         int max_yblen = MAX_BLOCKSIZE >> (i ? s->chroma_y_shift : 0);
325 325
         w = s->source.width  >> (i ? s->chroma_x_shift : 0);
326 326
         h = s->source.height >> (i ? s->chroma_y_shift : 0);
327 327
 
328
-        // we allocate the max we support here since num decompositions can
329
-        // change from frame to frame. Stride is aligned to 16 for SIMD, and
330
-        // 1<<MAX_DWT_LEVELS top padding to avoid if(y>0) in arith decoding
331
-        // MAX_BLOCKSIZE padding for MC: blocks can spill up to half of that
332
-        // on each side
328
+        /* we allocate the max we support here since num decompositions can
329
+         * change from frame to frame. Stride is aligned to 16 for SIMD, and
330
+         * 1<<MAX_DWT_LEVELS top padding to avoid if(y>0) in arith decoding
331
+         * MAX_BLOCKSIZE padding for MC: blocks can spill up to half of that
332
+         * on each side */
333 333
         top_padding = FFMAX(1<<MAX_DWT_LEVELS, max_yblen/2);
334
-        w = FFALIGN(CALC_PADDING(w, MAX_DWT_LEVELS), 8); //FIXME: Should this be 16 for SSE???
334
+        w = FFALIGN(CALC_PADDING(w, MAX_DWT_LEVELS), 8); /* FIXME: Should this be 16 for SSE??? */
335 335
         h = top_padding + CALC_PADDING(h, MAX_DWT_LEVELS) + max_yblen/2;
336 336
 
337 337
         s->plane[i].idwt_buf_base = av_mallocz((w+max_xblen)*h * sizeof(IDWTELEM));
... ...
@@ -344,7 +347,7 @@ static int alloc_sequence_buffers(DiracContext *s)
344 344
     w = s->source.width;
345 345
     h = s->source.height;
346 346
 
347
-    // fixme: allocate using real stride here
347
+    /* fixme: allocate using real stride here */
348 348
     s->sbsplit  = av_malloc(sbwidth * sbheight);
349 349
     s->blmotion = av_malloc(sbwidth * sbheight * 4 * sizeof(*s->blmotion));
350 350
     s->edge_emu_buffer_base = av_malloc((w+64)*MAX_BLOCKSIZE);
... ...
@@ -428,14 +431,14 @@ static inline void coeff_unpack_arith(DiracArith *c, int qfactor, int qoffset,
428 428
     int sign_pred = 0;
429 429
     int pred_ctx = CTX_ZPZN_F1;
430 430
 
431
-    // Check if the parent subband has a 0 in the corresponding position
431
+    /* Check if the parent subband has a 0 in the corresponding position */
432 432
     if (b->parent)
433 433
         pred_ctx += !!b->parent->ibuf[b->parent->stride * (y>>1) + (x>>1)] << 1;
434 434
 
435 435
     if (b->orientation == subband_hl)
436 436
         sign_pred = buf[-b->stride];
437 437
 
438
-    // Determine if the pixel has only zeros in its neighbourhood
438
+    /* Determine if the pixel has only zeros in its neighbourhood */
439 439
     if (x) {
440 440
         pred_ctx += !(buf[-1] | buf[-b->stride] | buf[-1-b->stride]);
441 441
         if (b->orientation == subband_lh)
... ...
@@ -479,7 +482,7 @@ static inline void codeblock(DiracContext *s, SubBand *b,
479 479
     int qoffset, qfactor;
480 480
     IDWTELEM *buf;
481 481
 
482
-    // check for any coded coefficients in this codeblock
482
+    /* check for any coded coefficients in this codeblock */
483 483
     if (!blockcnt_one) {
484 484
         if (is_arith)
485 485
             zero_block = dirac_get_arith_bit(c, CTX_ZERO_BLOCK);
... ...
@@ -500,7 +503,7 @@ static inline void codeblock(DiracContext *s, SubBand *b,
500 500
     b->quant = FFMIN(b->quant, MAX_QUANT);
501 501
 
502 502
     qfactor = qscale_tab[b->quant];
503
-    // TODO: context pointer?
503
+    /* TODO: context pointer? */
504 504
     if (!s->num_refs)
505 505
         qoffset = qoffset_intra_tab[b->quant];
506 506
     else
... ...
@@ -509,7 +512,7 @@ static inline void codeblock(DiracContext *s, SubBand *b,
509 509
     buf = b->ibuf + top*b->stride;
510 510
     for (y = top; y < bottom; y++) {
511 511
         for (x = left; x < right; x++) {
512
-          //[DIRAC_STD] 13.4.4 Subband coefficients. coeff_unpack()
512
+            /* [DIRAC_STD] 13.4.4 Subband coefficients. coeff_unpack() */
513 513
             if (is_arith)
514 514
                 coeff_unpack_arith(c, qfactor, qoffset, b, buf+x, x, y);
515 515
             else
... ...
@@ -519,7 +522,10 @@ static inline void codeblock(DiracContext *s, SubBand *b,
519 519
     }
520 520
 }
521 521
 
522
-//[DIRAC_STD] 13.3 intra_dc_prediction(band)
522
+/**
523
+ * Dirac Specification ->
524
+ * 13.3 intra_dc_prediction(band)
525
+ */
523 526
 static inline void intra_dc_prediction(SubBand *b)
524 527
 {
525 528
     IDWTELEM *buf = b->ibuf;
... ...
@@ -540,7 +546,10 @@ static inline void intra_dc_prediction(SubBand *b)
540 540
     }
541 541
 }
542 542
 
543
-//[DIRAC_STD] 13.4.2 Non-skipped subbands.  subband_coeffs()
543
+/**
544
+ * Dirac Specification ->
545
+ * 13.4.2 Non-skipped subbands.  subband_coeffs()
546
+ */
544 547
 static av_always_inline
545 548
 void decode_subband_internal(DiracContext *s, SubBand *b, int is_arith)
546 549
 {
... ...
@@ -590,7 +599,10 @@ static int decode_subband_golomb(AVCodecContext *avctx, void *arg)
590 590
     return 0;
591 591
 }
592 592
 
593
-//[DIRAC_STD] 13.4.1 core_transform_data()
593
+/**
594
+ * Dirac Specification ->
595
+ * [DIRAC_STD] 13.4.1 core_transform_data()
596
+ */
594 597
 static void decode_component(DiracContext *s, int comp)
595 598
 {
596 599
     AVCodecContext *avctx = s->avctx;
... ...
@@ -598,14 +610,14 @@ static void decode_component(DiracContext *s, int comp)
598 598
     enum dirac_subband orientation;
599 599
     int level, num_bands = 0;
600 600
 
601
-    // Unpack all subbands at all levels.
601
+    /* Unpack all subbands at all levels. */
602 602
     for (level = 0; level < s->wavelet_depth; level++) {
603 603
         for (orientation = !!level; orientation < 4; orientation++) {
604 604
             SubBand *b = &s->plane[comp].band[level][orientation];
605 605
             bands[num_bands++] = b;
606 606
 
607 607
             align_get_bits(&s->gb);
608
-            //[DIRAC_STD] 13.4.2 subband()
608
+            /* [DIRAC_STD] 13.4.2 subband() */
609 609
             b->length = svq3_get_ue_golomb(&s->gb);
610 610
             if (b->length) {
611 611
                 b->quant = svq3_get_ue_golomb(&s->gb);
... ...
@@ -615,18 +627,18 @@ static void decode_component(DiracContext *s, int comp)
615 615
                 skip_bits_long(&s->gb, b->length*8);
616 616
             }
617 617
         }
618
-        // arithmetic coding has inter-level dependencies, so we can only execute one level at a time
618
+        /* arithmetic coding has inter-level dependencies, so we can only execute one level at a time */
619 619
         if (s->is_arith)
620 620
             avctx->execute(avctx, decode_subband_arith, &s->plane[comp].band[level][!!level],
621 621
                            NULL, 4-!!level, sizeof(SubBand));
622 622
     }
623
-    // golomb coding has no inter-level dependencies, so we can execute all subbands in parallel
623
+    /* golomb coding has no inter-level dependencies, so we can execute all subbands in parallel */
624 624
     if (!s->is_arith)
625 625
         avctx->execute(avctx, decode_subband_golomb, bands, NULL, num_bands, sizeof(SubBand*));
626 626
 }
627 627
 
628
-//[DIRAC_STD] 13.5.5.2 Luma slice subband data. luma_slice_band(level,orient,sx,sy) --> if b2 == NULL
629
-//[DIRAC_STD] 13.5.5.3 Chroma slice subband data. chroma_slice_band(level,orient,sx,sy) --> if b2 != NULL
628
+/* [DIRAC_STD] 13.5.5.2 Luma slice subband data. luma_slice_band(level,orient,sx,sy) --> if b2 == NULL */
629
+/* [DIRAC_STD] 13.5.5.3 Chroma slice subband data. chroma_slice_band(level,orient,sx,sy) --> if b2 != NULL */
630 630
 static void lowdelay_subband(DiracContext *s, GetBitContext *gb, int quant,
631 631
                              int slice_x, int slice_y, int bits_end,
632 632
                              SubBand *b1, SubBand *b2)
... ...
@@ -642,8 +654,8 @@ static void lowdelay_subband(DiracContext *s, GetBitContext *gb, int quant,
642 642
     IDWTELEM *buf1 =      b1->ibuf + top*b1->stride;
643 643
     IDWTELEM *buf2 = b2 ? b2->ibuf + top*b2->stride : NULL;
644 644
     int x, y;
645
-    // we have to constantly check for overread since the spec explictly
646
-    // requires this, with the meaning that all remaining coeffs are set to 0
645
+    /* we have to constantly check for overread since the spec explictly
646
+       requires this, with the meaning that all remaining coeffs are set to 0 */
647 647
     if (get_bits_count(gb) >= bits_end)
648 648
         return;
649 649
 
... ...
@@ -672,7 +684,10 @@ struct lowdelay_slice {
672 672
 };
673 673
 
674 674
 
675
-//[DIRAC_STD] 13.5.2 Slices. slice(sx,sy)
675
+/**
676
+ * Dirac Specification ->
677
+ * 13.5.2 Slices. slice(sx,sy)
678
+ */
676 679
 static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
677 680
 {
678 681
     DiracContext *s = avctx->priv_data;
... ...
@@ -681,12 +696,12 @@ static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
681 681
     enum dirac_subband orientation;
682 682
     int level, quant, chroma_bits, chroma_end;
683 683
 
684
-    int quant_base  = get_bits(gb, 7); //[DIRAC_STD] qindex
684
+    int quant_base  = get_bits(gb, 7); /*[DIRAC_STD] qindex */
685 685
     int length_bits = av_log2(8*slice->bytes)+1;
686 686
     int luma_bits   = get_bits_long(gb, length_bits);
687 687
     int luma_end    = get_bits_count(gb) + FFMIN(luma_bits, get_bits_left(gb));
688 688
 
689
-    //[DIRAC_STD] 13.5.5.2 luma_slice_band
689
+    /* [DIRAC_STD] 13.5.5.2 luma_slice_band */
690 690
     for (level = 0; level < s->wavelet_depth; level++)
691 691
         for (orientation = !!level; orientation < 4; orientation++) {
692 692
             quant = FFMAX(quant_base - s->lowdelay.quant[level][orientation], 0);
... ...
@@ -694,12 +709,12 @@ static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
694 694
                              &s->plane[0].band[level][orientation], NULL);
695 695
         }
696 696
 
697
-    // consume any unused bits from luma
697
+    /* consume any unused bits from luma */
698 698
     skip_bits_long(gb, get_bits_count(gb) - luma_end);
699 699
 
700 700
     chroma_bits = 8*slice->bytes - 7 - length_bits - luma_bits;
701 701
     chroma_end = get_bits_count(gb) + FFMIN(chroma_bits, get_bits_left(gb));
702
-    //[DIRAC_STD] 13.5.5.3 chroma_slice_band
702
+    /* [DIRAC_STD] 13.5.5.3 chroma_slice_band */
703 703
     for (level = 0; level < s->wavelet_depth; level++)
704 704
         for (orientation = !!level; orientation < 4; orientation++) {
705 705
             quant = FFMAX(quant_base - s->lowdelay.quant[level][orientation], 0);
... ...
@@ -711,7 +726,10 @@ static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
711 711
     return 0;
712 712
 }
713 713
 
714
-//[DIRAC_STD] 13.5.1 low_delay_transform_data()
714
+/**
715
+ * Dirac Specification ->
716
+ * 13.5.1 low_delay_transform_data()
717
+ */
715 718
 static void decode_lowdelay(DiracContext *s)
716 719
 {
717 720
     AVCodecContext *avctx = s->avctx;
... ...
@@ -723,14 +741,14 @@ static void decode_lowdelay(DiracContext *s)
723 723
     slices = av_mallocz(s->lowdelay.num_x * s->lowdelay.num_y * sizeof(struct lowdelay_slice));
724 724
 
725 725
     align_get_bits(&s->gb);
726
-    //[DIRAC_STD] 13.5.2 Slices. slice(sx,sy)
726
+    /*[DIRAC_STD] 13.5.2 Slices. slice(sx,sy) */
727 727
     buf = s->gb.buffer + get_bits_count(&s->gb)/8;
728 728
     bufsize = get_bits_left(&s->gb);
729 729
 
730 730
     for (slice_y = 0; slice_y < s->lowdelay.num_y; slice_y++)
731 731
         for (slice_x = 0; slice_x < s->lowdelay.num_x; slice_x++) {
732 732
             bytes = (slice_num+1) * s->lowdelay.bytes.num / s->lowdelay.bytes.den
733
-                   - slice_num    * s->lowdelay.bytes.num / s->lowdelay.bytes.den;
733
+                - slice_num    * s->lowdelay.bytes.num / s->lowdelay.bytes.den;
734 734
 
735 735
             slices[slice_num].bytes   = bytes;
736 736
             slices[slice_num].slice_x = slice_x;
... ...
@@ -746,11 +764,10 @@ static void decode_lowdelay(DiracContext *s)
746 746
 end:
747 747
 
748 748
     avctx->execute(avctx, decode_lowdelay_slice, slices, NULL, slice_num,
749
-                   sizeof(struct lowdelay_slice)); //[DIRAC_STD] 13.5.2 Slices
750
-    intra_dc_prediction(&s->plane[0].band[0][0]); //[DIRAC_STD] 13.3 intra_dc_prediction()
751
-    intra_dc_prediction(&s->plane[1].band[0][0]); //[DIRAC_STD] 13.3 intra_dc_prediction()
752
-    intra_dc_prediction(&s->plane[2].band[0][0]); //[DIRAC_STD] 13.3 intra_dc_prediction()
753
-
749
+                   sizeof(struct lowdelay_slice)); /* [DIRAC_STD] 13.5.2 Slices */
750
+    intra_dc_prediction(&s->plane[0].band[0][0]);  /* [DIRAC_STD] 13.3 intra_dc_prediction() */
751
+    intra_dc_prediction(&s->plane[1].band[0][0]);  /* [DIRAC_STD] 13.3 intra_dc_prediction() */
752
+    intra_dc_prediction(&s->plane[2].band[0][0]);  /* [DIRAC_STD] 13.3 intra_dc_prediction() */
754 753
     av_free(slices);
755 754
 }
756 755
 
... ...
@@ -804,7 +821,8 @@ static void init_planes(DiracContext *s)
804 804
 
805 805
 /**
806 806
  * Unpack the motion compensation parameters
807
- * [DIRAC_STD] 11.2 Picture prediction data. picture_prediction()
807
+ * Dirac Specification ->
808
+ * 11.2 Picture prediction data. picture_prediction()
808 809
  */
809 810
 static int dirac_unpack_prediction_parameters(DiracContext *s)
810 811
 {
... ...
@@ -815,15 +833,15 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
815 815
     unsigned idx, ref;
816 816
 
817 817
     align_get_bits(gb);
818
-    //[DIRAC_STD] 11.2.2 Block parameters. block_parameters()
819
-    //Luma and Chroma are equal. 11.2.3
820
-    idx = svq3_get_ue_golomb(gb); ////[DIRAC_STD] index
818
+    /* [DIRAC_STD] 11.2.2 Block parameters. block_parameters() */
819
+    /* Luma and Chroma are equal. 11.2.3 */
820
+    idx = svq3_get_ue_golomb(gb); /* [DIRAC_STD] index */
821 821
 
822 822
     if (idx > 4)
823
-      {
824
-         av_log(s->avctx, AV_LOG_ERROR, "Block prediction index too high\n");
823
+    {
824
+        av_log(s->avctx, AV_LOG_ERROR, "Block prediction index too high\n");
825 825
         return -1;
826
-      }
826
+    }
827 827
 
828 828
     if (idx == 0) {
829 829
         s->plane[0].xblen = svq3_get_ue_golomb(gb);
... ...
@@ -831,13 +849,14 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
831 831
         s->plane[0].xbsep = svq3_get_ue_golomb(gb);
832 832
         s->plane[0].ybsep = svq3_get_ue_golomb(gb);
833 833
     } else {
834
-      //[DIRAC_STD] preset_block_params(index). Table 11.1
834
+        /*[DIRAC_STD] preset_block_params(index). Table 11.1 */
835 835
         s->plane[0].xblen = default_blen[idx-1];
836 836
         s->plane[0].yblen = default_blen[idx-1];
837 837
         s->plane[0].xbsep = default_bsep[idx-1];
838 838
         s->plane[0].ybsep = default_bsep[idx-1];
839 839
     }
840
-    //[DIRAC_STD] 11.2.4 motion_data_dimensions() --> Calculated in function dirac_unpack_block_motion_data
840
+    /*[DIRAC_STD] 11.2.4 motion_data_dimensions()
841
+      Calculated in function dirac_unpack_block_motion_data */
841 842
 
842 843
     if (s->plane[0].xbsep < s->plane[0].xblen/2 || s->plane[0].ybsep < s->plane[0].yblen/2) {
843 844
         av_log(s->avctx, AV_LOG_ERROR, "Block separation too small\n");
... ...
@@ -852,27 +871,27 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
852 852
         return -1;
853 853
     }
854 854
 
855
-    //[DIRAC_STD] 11.2.5 Motion vector precision. motion_vector_precision()
856
-    // Read motion vector precision
855
+    /*[DIRAC_STD] 11.2.5 Motion vector precision. motion_vector_precision()
856
+      Read motion vector precision */
857 857
     s->mv_precision = svq3_get_ue_golomb(gb);
858 858
     if (s->mv_precision > 3) {
859 859
         av_log(s->avctx, AV_LOG_ERROR, "MV precision finer than eighth-pel\n");
860 860
         return -1;
861 861
     }
862 862
 
863
-    //[DIRAC_STD] 11.2.6 Global motion. global_motion()
864
-    // Read the global motion compensation parameters
863
+    /*[DIRAC_STD] 11.2.6 Global motion. global_motion()
864
+      Read the global motion compensation parameters */
865 865
     s->globalmc_flag = get_bits1(gb);
866 866
     if (s->globalmc_flag) {
867 867
         memset(s->globalmc, 0, sizeof(s->globalmc));
868
-        //[DIRAC_STD] pan_tilt(gparams)
868
+        /* [DIRAC_STD] pan_tilt(gparams) */
869 869
         for (ref = 0; ref < s->num_refs; ref++) {
870 870
             if (get_bits1(gb)) {
871 871
                 s->globalmc[ref].pan_tilt[0] = dirac_get_se_golomb(gb);
872 872
                 s->globalmc[ref].pan_tilt[1] = dirac_get_se_golomb(gb);
873 873
             }
874
-            //[DIRAC_STD] zoom_rotate_shear(gparams)
875
-            // zoom/rotation/shear parameters
874
+            /* [DIRAC_STD] zoom_rotate_shear(gparams)
875
+               zoom/rotation/shear parameters */
876 876
             if (get_bits1(gb)) {
877 877
                 s->globalmc[ref].zrs_exp = svq3_get_ue_golomb(gb);
878 878
                 s->globalmc[ref].zrs[0][0] = dirac_get_se_golomb(gb);
... ...
@@ -883,7 +902,7 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
883 883
                 s->globalmc[ref].zrs[0][0] = 1;
884 884
                 s->globalmc[ref].zrs[1][1] = 1;
885 885
             }
886
-            //[DIRAC_STD] perspective(gparams)
886
+            /* [DIRAC_STD] perspective(gparams) */
887 887
             if (get_bits1(gb)) {
888 888
                 s->globalmc[ref].perspective_exp = svq3_get_ue_golomb(gb);
889 889
                 s->globalmc[ref].perspective[0] = dirac_get_se_golomb(gb);
... ...
@@ -892,15 +911,15 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
892 892
         }
893 893
     }
894 894
 
895
-    //[DIRAC_STD] 11.2.7 Picture prediction mode. prediction_mode()
896
-    // Picture prediction mode, not currently used.
895
+    /*[DIRAC_STD] 11.2.7 Picture prediction mode. prediction_mode()
896
+      Picture prediction mode, not currently used. */
897 897
     if (svq3_get_ue_golomb(gb)) {
898 898
         av_log(s->avctx, AV_LOG_ERROR, "Unknown picture prediction mode\n");
899 899
         return -1;
900 900
     }
901 901
 
902
-    //[DIRAC_STD] 11.2.8 Reference picture weight. reference_picture_weights()
903
-    //just data read, weight calculation will be done later on.
902
+    /* [DIRAC_STD] 11.2.8 Reference picture weight. reference_picture_weights()
903
+       just data read, weight calculation will be done later on. */
904 904
     s->weight_log2denom = 1;
905 905
     s->weight[0]        = 1;
906 906
     s->weight[1]        = 1;
... ...
@@ -914,7 +933,10 @@ static int dirac_unpack_prediction_parameters(DiracContext *s)
914 914
     return 0;
915 915
 }
916 916
 
917
-//[DIRAC_STD] 11.3 Wavelet transform data. wavelet_transform()
917
+/**
918
+ * Dirac Specification ->
919
+ * 11.3 Wavelet transform data. wavelet_transform()
920
+ */
918 921
 static int dirac_unpack_idwt_params(DiracContext *s)
919 922
 {
920 923
     GetBitContext *gb = &s->gb;
... ...
@@ -926,7 +948,7 @@ static int dirac_unpack_idwt_params(DiracContext *s)
926 926
     if (s->zero_res)
927 927
         return 0;
928 928
 
929
-    //[DIRAC_STD] 11.3.1 Transform parameters. transform_parameters()
929
+    /*[DIRAC_STD] 11.3.1 Transform parameters. transform_parameters() */
930 930
     s->wavelet_idx = svq3_get_ue_golomb(gb);
931 931
     if (s->wavelet_idx > 6)
932 932
         return -1;
... ...
@@ -954,17 +976,17 @@ static int dirac_unpack_idwt_params(DiracContext *s)
954 954
             for (i = 0; i <= s->wavelet_depth; i++)
955 955
                 s->codeblock[i].width = s->codeblock[i].height = 1;
956 956
     } else {
957
-      /* Slice parameters + quantization matrix*/
958
-      //[DIRAC_STD] 11.3.4 Slice coding Parameters (low delay syntax only). slice_parameters()
957
+        /* Slice parameters + quantization matrix*/
958
+        /*[DIRAC_STD] 11.3.4 Slice coding Parameters (low delay syntax only). slice_parameters() */
959 959
         s->lowdelay.num_x     = svq3_get_ue_golomb(gb);
960 960
         s->lowdelay.num_y     = svq3_get_ue_golomb(gb);
961 961
         s->lowdelay.bytes.num = svq3_get_ue_golomb(gb);
962 962
         s->lowdelay.bytes.den = svq3_get_ue_golomb(gb);
963 963
 
964
-        //[DIRAC_STD] 11.3.5 Quantisation matrices (low-delay syntax). quant_matrix()
964
+        /* [DIRAC_STD] 11.3.5 Quantisation matrices (low-delay syntax). quant_matrix() */
965 965
         if (get_bits1(gb)) {
966
-          av_log(s->avctx,AV_LOG_DEBUG,"Low Delay: Has Custom Quantization Matrix!\n");
967
-            // custom quantization matrix
966
+            av_log(s->avctx,AV_LOG_DEBUG,"Low Delay: Has Custom Quantization Matrix!\n");
967
+            /* custom quantization matrix */
968 968
             s->lowdelay.quant[0][0] = svq3_get_ue_golomb(gb);
969 969
             for (level = 0; level < s->wavelet_depth; level++) {
970 970
                 s->lowdelay.quant[level][1] = svq3_get_ue_golomb(gb);
... ...
@@ -972,11 +994,11 @@ static int dirac_unpack_idwt_params(DiracContext *s)
972 972
                 s->lowdelay.quant[level][3] = svq3_get_ue_golomb(gb);
973 973
             }
974 974
         } else {
975
-            // default quantization matrix
975
+            /* default quantization matrix */
976 976
             for (level = 0; level < s->wavelet_depth; level++)
977 977
                 for (i = 0; i < 4; i++) {
978 978
                     s->lowdelay.quant[level][i] = default_qmat[s->wavelet_idx][level][i];
979
-                    // haar with no shift differs for different depths
979
+                    /* haar with no shift differs for different depths */
980 980
                     if (s->wavelet_idx == 3)
981 981
                         s->lowdelay.quant[level][i] += 4*(s->wavelet_depth-1 - level);
982 982
                 }
... ...
@@ -1010,7 +1032,7 @@ static inline int pred_block_mode(DiracBlock *block, int stride, int x, int y, i
1010 1010
     else if (!x)
1011 1011
         return block[-stride].ref & refmask;
1012 1012
 
1013
-    // return the majority
1013
+    /* return the majority */
1014 1014
     pred = (block[-1].ref & refmask) + (block[-stride].ref & refmask) + (block[-stride-1].ref & refmask);
1015 1015
     return (pred >> 1) & refmask;
1016 1016
 }
... ...
@@ -1052,7 +1074,7 @@ static inline void pred_mv(DiracBlock *block, int stride, int x, int y, int ref)
1052 1052
 {
1053 1053
     int16_t *pred[3];
1054 1054
     int refmask = ref+1;
1055
-    int mask = refmask | DIRAC_REF_MASK_GLOBAL; // exclude gmc blocks
1055
+    int mask = refmask | DIRAC_REF_MASK_GLOBAL; /*  exclude gmc blocks */
1056 1056
     int n = 0;
1057 1057
 
1058 1058
     if (x && (block[-1].ref & mask) == refmask)
... ...
@@ -1155,7 +1177,10 @@ static void propagate_block_data(DiracBlock *block, int stride, int size)
1155 1155
     }
1156 1156
 }
1157 1157
 
1158
-//[DIRAC_STD] 12. Block motion data syntax
1158
+/**
1159
+ * Dirac Specification ->
1160
+ * 12. Block motion data syntax
1161
+ */
1159 1162
 static void dirac_unpack_block_motion_data(DiracContext *s)
1160 1163
 {
1161 1164
     GetBitContext *gb = &s->gb;
... ...
@@ -1165,15 +1190,15 @@ static void dirac_unpack_block_motion_data(DiracContext *s)
1165 1165
 
1166 1166
     align_get_bits(gb);
1167 1167
 
1168
-    //[DIRAC_STD] 11.2.4 and 12.2.1 Number of blocks and superblocks
1168
+    /* [DIRAC_STD] 11.2.4 and 12.2.1 Number of blocks and superblocks */
1169 1169
     s->sbwidth  = DIVRNDUP(s->source.width,  4*s->plane[0].xbsep);
1170 1170
     s->sbheight = DIVRNDUP(s->source.height, 4*s->plane[0].ybsep);
1171 1171
     s->blwidth  = 4*s->sbwidth;
1172 1172
     s->blheight = 4*s->sbheight;
1173 1173
 
1174
-    //[DIRAC_STD] 12.3.1 Superblock splitting modes. superblock_split_modes()
1175
-    // decode superblock split modes
1176
-    ff_dirac_init_arith_decoder(arith, gb, svq3_get_ue_golomb(gb));     //svq3_get_ue_golomb(gb) is the length
1174
+    /* [DIRAC_STD] 12.3.1 Superblock splitting modes. superblock_split_modes()
1175
+       decode superblock split modes */
1176
+    ff_dirac_init_arith_decoder(arith, gb, svq3_get_ue_golomb(gb));     /* svq3_get_ue_golomb(gb) is the length */
1177 1177
     for (y = 0; y < s->sbheight; y++) {
1178 1178
         for (x = 0; x < s->sbwidth; x++) {
1179 1179
             int split = dirac_get_arith_uint(arith, CTX_SB_F1, CTX_SB_DATA);
... ...
@@ -1182,7 +1207,7 @@ static void dirac_unpack_block_motion_data(DiracContext *s)
1182 1182
         sbsplit += s->sbwidth;
1183 1183
     }
1184 1184
 
1185
-    // setup arith decoding
1185
+    /* setup arith decoding */
1186 1186
     ff_dirac_init_arith_decoder(arith, gb, svq3_get_ue_golomb(gb));
1187 1187
     for (i = 0; i < s->num_refs; i++) {
1188 1188
         ff_dirac_init_arith_decoder(arith+4+2*i, gb, svq3_get_ue_golomb(gb));
... ...
@@ -1209,7 +1234,7 @@ static void dirac_unpack_block_motion_data(DiracContext *s)
1209 1209
 
1210 1210
 static int weight(int i, int blen, int offset)
1211 1211
 {
1212
-#define ROLLOFF(i) offset == 1 ? ((i) ? 5 : 3) : \
1212
+#define ROLLOFF(i) offset == 1 ? ((i) ? 5 : 3) :        \
1213 1213
     (1 + (6*(i) + offset - 1) / (2*offset - 1))
1214 1214
 
1215 1215
     if (i < 2*offset)
... ...
@@ -1257,7 +1282,7 @@ static void init_obmc_weights(DiracContext *s, Plane *p, int by)
1257 1257
     int top = !by;
1258 1258
     int bottom = by == s->blheight-1;
1259 1259
 
1260
-    // don't bother re-initing for rows 2 to blheight-2, the weights don't change
1260
+    /* don't bother re-initing for rows 2 to blheight-2, the weights don't change */
1261 1261
     if (top || bottom || by == 1) {
1262 1262
         init_obmc_weight(p, s->obmc_weight[0], MAX_BLOCKSIZE, 1, 0, top, bottom);
1263 1263
         init_obmc_weight(p, s->obmc_weight[1], MAX_BLOCKSIZE, 0, 0, top, bottom);
... ...
@@ -1310,8 +1335,8 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
1310 1310
     my = motion_y & ~(-1 << s->mv_precision);
1311 1311
     motion_x >>= s->mv_precision;
1312 1312
     motion_y >>= s->mv_precision;
1313
-    // normalize subpel coordinates to epel
1314
-    // TODO: template this function?
1313
+    /* normalize subpel coordinates to epel */
1314
+    /* TODO: template this function? */
1315 1315
     mx <<= 3-s->mv_precision;
1316 1316
     my <<= 3-s->mv_precision;
1317 1317
 
... ...
@@ -1319,18 +1344,18 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
1319 1319
     y += motion_y;
1320 1320
     epel = (mx|my)&1;
1321 1321
 
1322
-    // hpel position
1322
+    /* hpel position */
1323 1323
     if (!((mx|my)&3)) {
1324 1324
         nplanes = 1;
1325 1325
         src[0] = ref_hpel[(my>>1)+(mx>>2)] + y*p->stride + x;
1326 1326
     } else {
1327
-        // qpel or epel
1327
+        /* qpel or epel */
1328 1328
         nplanes = 4;
1329 1329
         for (i = 0; i < 4; i++)
1330 1330
             src[i] = ref_hpel[i] + y*p->stride + x;
1331 1331
 
1332
-        // if we're interpolating in the right/bottom halves, adjust the planes as needed
1333
-        // we increment x/y because the edge changes for half of the pixels
1332
+        /* if we're interpolating in the right/bottom halves, adjust the planes as needed
1333
+           we increment x/y because the edge changes for half of the pixels */
1334 1334
         if (mx > 4) {
1335 1335
             src[0] += 1;
1336 1336
             src[2] += 1;
... ...
@@ -1342,15 +1367,15 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
1342 1342
             y++;
1343 1343
         }
1344 1344
 
1345
-        // hpel planes are:
1346
-        // [0]: F  [1]: H
1347
-        // [2]: V  [3]: C
1345
+        /* hpel planes are:
1346
+           [0]: F  [1]: H
1347
+           [2]: V  [3]: C */
1348 1348
         if (!epel) {
1349
-            // check if we really only need 2 planes since either mx or my is
1350
-            // a hpel position. (epel weights of 0 handle this there)
1349
+            /* check if we really only need 2 planes since either mx or my is
1350
+               a hpel position. (epel weights of 0 handle this there) */
1351 1351
             if (!(mx&3)) {
1352
-                // mx == 0: average [0] and [2]
1353
-                // mx == 4: average [1] and [3]
1352
+                /* mx == 0: average [0] and [2]
1353
+                   mx == 4: average [1] and [3] */
1354 1354
                 src[!mx] = src[2 + !!mx];
1355 1355
                 nplanes = 2;
1356 1356
             } else if (!(my&3)) {
... ...
@@ -1359,7 +1384,7 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
1359 1359
                 nplanes = 2;
1360 1360
             }
1361 1361
         } else {
1362
-            // adjust the ordering if needed so the weights work
1362
+            /* adjust the ordering if needed so the weights work */
1363 1363
             if (mx > 4) {
1364 1364
                 FFSWAP(const uint8_t *, src[0], src[1]);
1365 1365
                 FFSWAP(const uint8_t *, src[2], src[3]);
... ...
@@ -1372,7 +1397,7 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5],
1372 1372
         }
1373 1373
     }
1374 1374
 
1375
-    // fixme: v/h _edge_pos
1375
+    /* fixme: v/h _edge_pos */
1376 1376
     if ((unsigned)x > p->width +EDGE_WIDTH/2 - p->xblen ||
1377 1377
         (unsigned)y > p->height+EDGE_WIDTH/2 - p->yblen) {
1378 1378
         for (i = 0; i < nplanes; i++) {
... ...
@@ -1410,7 +1435,7 @@ static void block_mc(DiracContext *s, DiracBlock *block,
1410 1410
     int idx;
1411 1411
 
1412 1412
     switch (block->ref&3) {
1413
-    case 0: // DC
1413
+    case 0: /* DC */
1414 1414
         add_dc(mctmp, block->u.dc[plane], p->stride, obmc_weight, p->xblen, p->yblen);
1415 1415
         return;
1416 1416
     case 1:
... ...
@@ -1426,7 +1451,7 @@ static void block_mc(DiracContext *s, DiracBlock *block,
1426 1426
         s->put_pixels_tab[idx](s->mcscratch, src, p->stride, p->yblen);
1427 1427
         idx = mc_subpel(s, block, src, dstx, dsty, 1, plane);
1428 1428
         if (s->biweight_func) {
1429
-            // fixme: +32 is a quick hack
1429
+            /* fixme: +32 is a quick hack */
1430 1430
             s->put_pixels_tab[idx](s->mcscratch + 32, src, p->stride, p->yblen);
1431 1431
             s->biweight_func(s->mcscratch, s->mcscratch+32, p->stride, s->weight_log2denom,
1432 1432
                              s->weight[0], s->weight[1], p->yblen);
... ...
@@ -1475,22 +1500,22 @@ static void select_dsp_funcs(DiracContext *s, int width, int height, int xblen,
1475 1475
 
1476 1476
 static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, int width, int height)
1477 1477
 {
1478
-    // chroma allocates an edge of 8 when subsampled
1479
-    // which for 4:2:2 means an h edge of 16 and v edge of 8
1480
-    // just use 8 for everything for the moment
1478
+    /* chroma allocates an edge of 8 when subsampled
1479
+       which for 4:2:2 means an h edge of 16 and v edge of 8
1480
+       just use 8 for everything for the moment */
1481 1481
     int i, edge = EDGE_WIDTH/2;
1482 1482
 
1483 1483
     ref->hpel[plane][0] = ref->avframe.data[plane];
1484
-    s->dsp.draw_edges(ref->hpel[plane][0], ref->avframe.linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM); //EDGE_TOP | EDGE_BOTTOM values just copied to make it build, this needs to be ensured
1484
+    s->dsp.draw_edges(ref->hpel[plane][0], ref->avframe.linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM); /* EDGE_TOP | EDGE_BOTTOM values just copied to make it build, this needs to be ensured */
1485 1485
 
1486
-    // no need for hpel if we only have fpel vectors
1486
+    /* no need for hpel if we only have fpel vectors */
1487 1487
     if (!s->mv_precision)
1488 1488
         return;
1489 1489
 
1490 1490
     for (i = 1; i < 4; i++) {
1491 1491
         if (!ref->hpel_base[plane][i])
1492 1492
             ref->hpel_base[plane][i] = av_malloc((height+2*edge) * ref->avframe.linesize[plane] + 32);
1493
-        // we need to be 16-byte aligned even for chroma
1493
+        /* we need to be 16-byte aligned even for chroma */
1494 1494
         ref->hpel[plane][i] = ref->hpel_base[plane][i] + edge*ref->avframe.linesize[plane] + 16;
1495 1495
     }
1496 1496
 
... ...
@@ -1505,102 +1530,108 @@ static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, in
1505 1505
     ref->interpolated[plane] = 1;
1506 1506
 }
1507 1507
 
1508
-//[DIRAC_STD] 13.0 Transform data syntax. transform_data()
1508
+/**
1509
+ * Dirac Specification ->
1510
+ * 13.0 Transform data syntax. transform_data()
1511
+ */
1509 1512
 static int dirac_decode_frame_internal(DiracContext *s)
1510 1513
 {
1511
-  DWTContext d;
1512
-  int y, i, comp, dsty;
1514
+    DWTContext d;
1515
+    int y, i, comp, dsty;
1516
+
1517
+    if (s->low_delay) {
1518
+        /* [DIRAC_STD] 13.5.1 low_delay_transform_data() */
1519
+        for (comp = 0; comp < 3; comp++) {
1520
+            Plane *p = &s->plane[comp];
1521
+            memset(p->idwt_buf, 0, p->idwt_stride * p->idwt_height * sizeof(IDWTELEM));
1522
+        }
1523
+        if (!s->zero_res)
1524
+            decode_lowdelay(s);
1525
+    }
1513 1526
 
1514
-  if (s->low_delay) {
1515
-    //[DIRAC_STD] 13.5.1 low_delay_transform_data()
1516 1527
     for (comp = 0; comp < 3; comp++) {
1517
-      Plane *p = &s->plane[comp];
1518
-      memset(p->idwt_buf, 0, p->idwt_stride * p->idwt_height * sizeof(IDWTELEM));
1519
-    }
1520
-    if (!s->zero_res)
1521
-      decode_lowdelay(s);
1522
-  }
1523
-
1524
-  for (comp = 0; comp < 3; comp++) {
1525
-    Plane *p = &s->plane[comp];
1526
-    uint8_t *frame = s->current_picture->avframe.data[comp];
1527
-
1528
-    // FIXME: small resolutions
1529
-    for (i = 0; i < 4; i++)
1530
-      s->edge_emu_buffer[i] = s->edge_emu_buffer_base + i*FFALIGN(p->width, 16);
1531
-
1532
-    if (!s->zero_res && !s->low_delay)
1533
-      {
1534
-        memset(p->idwt_buf, 0, p->idwt_stride * p->idwt_height * sizeof(IDWTELEM));
1535
-          decode_component(s, comp); //[DIRAC_STD] 13.4.1 core_transform_data()
1536
-      }
1537
-    if (ff_spatial_idwt_init2(&d, p->idwt_buf, p->idwt_width, p->idwt_height, p->idwt_stride,
1538
-                              s->wavelet_idx+2, s->wavelet_depth, p->idwt_tmp))
1539
-        return -1;
1528
+        Plane *p = &s->plane[comp];
1529
+        uint8_t *frame = s->current_picture->avframe.data[comp];
1530
+
1531
+        /* FIXME: small resolutions */
1532
+        for (i = 0; i < 4; i++)
1533
+            s->edge_emu_buffer[i] = s->edge_emu_buffer_base + i*FFALIGN(p->width, 16);
1540 1534
 
1541
-    if (!s->num_refs) { //intra
1542
-      for (y = 0; y < p->height; y += 16) {
1543
-        ff_spatial_idwt_slice2(&d, y+16); //decode
1544
-        s->diracdsp.put_signed_rect_clamped(frame + y*p->stride, p->stride,
1545
-                                            p->idwt_buf + y*p->idwt_stride, p->idwt_stride, p->width, 16);
1546
-      }
1547
-    } else { //inter
1548
-      int rowheight = p->ybsep*p->stride;
1535
+        if (!s->zero_res && !s->low_delay)
1536
+        {
1537
+            memset(p->idwt_buf, 0, p->idwt_stride * p->idwt_height * sizeof(IDWTELEM));
1538
+            decode_component(s, comp); /* [DIRAC_STD] 13.4.1 core_transform_data() */
1539
+        }
1540
+        if (ff_spatial_idwt_init2(&d, p->idwt_buf, p->idwt_width, p->idwt_height, p->idwt_stride,
1541
+                                  s->wavelet_idx+2, s->wavelet_depth, p->idwt_tmp))
1542
+            return -1;
1549 1543
 
1550
-      select_dsp_funcs(s, p->width, p->height, p->xblen, p->yblen);
1544
+        if (!s->num_refs) { /* intra */
1545
+            for (y = 0; y < p->height; y += 16) {
1546
+                ff_spatial_idwt_slice2(&d, y+16); /* decode */
1547
+                s->diracdsp.put_signed_rect_clamped(frame + y*p->stride, p->stride,
1548
+                                                    p->idwt_buf + y*p->idwt_stride, p->idwt_stride, p->width, 16);
1549
+            }
1550
+        } else { /* inter */
1551
+            int rowheight = p->ybsep*p->stride;
1551 1552
 
1552
-      for (i = 0; i < s->num_refs; i++)
1553
-        interpolate_refplane(s, s->ref_pics[i], comp, p->width, p->height);
1553
+            select_dsp_funcs(s, p->width, p->height, p->xblen, p->yblen);
1554 1554
 
1555
-      memset(s->mctmp, 0, 4*p->yoffset*p->stride);
1555
+            for (i = 0; i < s->num_refs; i++)
1556
+                interpolate_refplane(s, s->ref_pics[i], comp, p->width, p->height);
1556 1557
 
1557
-      dsty = -p->yoffset;
1558
-      for (y = 0; y < s->blheight; y++) {
1559
-        int h = 0, start = FFMAX(dsty, 0);
1560
-        uint16_t *mctmp = s->mctmp + y*rowheight;
1561
-        DiracBlock *blocks = s->blmotion + y*s->blwidth;
1558
+            memset(s->mctmp, 0, 4*p->yoffset*p->stride);
1562 1559
 
1563
-        init_obmc_weights(s, p, y);
1560
+            dsty = -p->yoffset;
1561
+            for (y = 0; y < s->blheight; y++) {
1562
+                int h = 0, start = FFMAX(dsty, 0);
1563
+                uint16_t *mctmp = s->mctmp + y*rowheight;
1564
+                DiracBlock *blocks = s->blmotion + y*s->blwidth;
1564 1565
 
1565
-        if (y == s->blheight-1 || start+p->ybsep > p->height)
1566
-          h = p->height - start;
1567
-        else
1568
-          h = p->ybsep - (start - dsty);
1569
-        if (h < 0)
1570
-          break;
1566
+                init_obmc_weights(s, p, y);
1571 1567
 
1572
-        memset(mctmp+2*p->yoffset*p->stride, 0, 2*rowheight);
1573
-        mc_row(s, blocks, mctmp, comp, dsty);
1568
+                if (y == s->blheight-1 || start+p->ybsep > p->height)
1569
+                    h = p->height - start;
1570
+                else
1571
+                    h = p->ybsep - (start - dsty);
1572
+                if (h < 0)
1573
+                    break;
1574 1574
 
1575
-        mctmp += (start - dsty)*p->stride + p->xoffset;
1576
-        ff_spatial_idwt_slice2(&d, start + h); //decode
1577
-        s->diracdsp.add_rect_clamped(frame + start*p->stride, mctmp, p->stride,
1578
-                                     p->idwt_buf + start*p->idwt_stride, p->idwt_stride, p->width, h);
1575
+                memset(mctmp+2*p->yoffset*p->stride, 0, 2*rowheight);
1576
+                mc_row(s, blocks, mctmp, comp, dsty);
1579 1577
 
1580
-        dsty += p->ybsep;
1581
-      }
1578
+                mctmp += (start - dsty)*p->stride + p->xoffset;
1579
+                ff_spatial_idwt_slice2(&d, start + h); /* decode */
1580
+                s->diracdsp.add_rect_clamped(frame + start*p->stride, mctmp, p->stride,
1581
+                                             p->idwt_buf + start*p->idwt_stride, p->idwt_stride, p->width, h);
1582
+
1583
+                dsty += p->ybsep;
1584
+            }
1585
+        }
1582 1586
     }
1583
-  }
1584 1587
 
1585 1588
 
1586
-  return 0;
1589
+    return 0;
1587 1590
 }
1588 1591
 
1589
-//[DIRAC_STD] 11.1.1 Picture Header. picture_header()
1592
+/**
1593
+ * Dirac Specification ->
1594
+ * 11.1.1 Picture Header. picture_header()
1595
+ */
1590 1596
 static int dirac_decode_picture_header(DiracContext *s)
1591 1597
 {
1592 1598
     int retire, picnum;
1593 1599
     int i, j, refnum, refdist;
1594 1600
     GetBitContext *gb = &s->gb;
1595 1601
 
1596
-    //[DIRAC_STD] 11.1.1 Picture Header. picture_header() PICTURE_NUM
1602
+    /* [DIRAC_STD] 11.1.1 Picture Header. picture_header() PICTURE_NUM */
1597 1603
     picnum = s->current_picture->avframe.display_picture_number = get_bits_long(gb, 32);
1598 1604
 
1599 1605
 
1600 1606
     av_log(s->avctx,AV_LOG_DEBUG,"PICTURE_NUM: %d\n",picnum);
1601 1607
 
1602
-    // if this is the first keyframe after a sequence header, start our
1603
-    // reordering from here
1608
+    /* if this is the first keyframe after a sequence header, start our
1609
+       reordering from here */
1604 1610
     if (s->frame_number < 0)
1605 1611
         s->frame_number = picnum;
1606 1612
 
... ...
@@ -1609,8 +1640,8 @@ static int dirac_decode_picture_header(DiracContext *s)
1609 1609
         refnum = picnum + dirac_get_se_golomb(gb);
1610 1610
         refdist = INT_MAX;
1611 1611
 
1612
-        // find the closest reference to the one we want
1613
-        // Jordi: this is needed if the referenced picture hasn't yet arrived
1612
+        /* find the closest reference to the one we want */
1613
+        /* Jordi: this is needed if the referenced picture hasn't yet arrived */
1614 1614
         for (j = 0; j < MAX_REFERENCE_FRAMES && refdist; j++)
1615 1615
             if (s->ref_frames[j]
1616 1616
                 && FFABS(s->ref_frames[j]->avframe.display_picture_number - refnum) < refdist) {
... ...
@@ -1621,7 +1652,7 @@ static int dirac_decode_picture_header(DiracContext *s)
1621 1621
         if (!s->ref_pics[i] || refdist)
1622 1622
             av_log(s->avctx, AV_LOG_DEBUG, "Reference not found\n");
1623 1623
 
1624
-        // if there were no references at all, allocate one
1624
+        /* if there were no references at all, allocate one */
1625 1625
         if (!s->ref_pics[i])
1626 1626
             for (j = 0; j < MAX_FRAMES; j++)
1627 1627
                 if (!s->all_frames[j].avframe.data[0]) {
... ...
@@ -1630,7 +1661,7 @@ static int dirac_decode_picture_header(DiracContext *s)
1630 1630
                 }
1631 1631
     }
1632 1632
 
1633
-    // retire the reference frames that are not used anymore
1633
+    /* retire the reference frames that are not used anymore */
1634 1634
     if (s->current_picture->avframe.reference) {
1635 1635
         retire = picnum + dirac_get_se_golomb(gb);
1636 1636
         if (retire != picnum) {
... ...
@@ -1642,7 +1673,7 @@ static int dirac_decode_picture_header(DiracContext *s)
1642 1642
                 av_log(s->avctx, AV_LOG_DEBUG, "Frame to retire not found\n");
1643 1643
         }
1644 1644
 
1645
-        // if reference array is full, remove the oldest as per the spec
1645
+        /* if reference array is full, remove the oldest as per the spec */
1646 1646
         while (add_frame(s->ref_frames, MAX_REFERENCE_FRAMES, s->current_picture)) {
1647 1647
             av_log(s->avctx, AV_LOG_ERROR, "Reference frame overflow\n");
1648 1648
             remove_frame(s->ref_frames, s->ref_frames[0]->avframe.display_picture_number)->avframe.reference &= DELAYED_PIC_REF;
... ...
@@ -1650,14 +1681,14 @@ static int dirac_decode_picture_header(DiracContext *s)
1650 1650
     }
1651 1651
 
1652 1652
     if (s->num_refs) {
1653
-      if (dirac_unpack_prediction_parameters(s))  //[DIRAC_STD] 11.2 Picture Prediction Data. picture_prediction()
1653
+        if (dirac_unpack_prediction_parameters(s))  /* [DIRAC_STD] 11.2 Picture Prediction Data. picture_prediction() */
1654 1654
             return -1;
1655
-      dirac_unpack_block_motion_data(s); //[DIRAC_STD] 12. Block motion data syntax
1655
+        dirac_unpack_block_motion_data(s);          /* [DIRAC_STD] 12. Block motion data syntax                       */
1656 1656
     }
1657
-    if (dirac_unpack_idwt_params(s)) //[DIRAC_STD] 11.3 Wavelet transform data
1657
+    if (dirac_unpack_idwt_params(s))                /* [DIRAC_STD] 11.3 Wavelet transform data                        */
1658 1658
         return -1;
1659 1659
 
1660
-    init_planes(s); //Jordi... ????
1660
+    init_planes(s);
1661 1661
     return 0;
1662 1662
 }
1663 1663
 
... ...
@@ -1666,7 +1697,7 @@ static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *data_size)
1666 1666
     DiracFrame *out = s->delay_frames[0];
1667 1667
     int i, out_idx = 0;
1668 1668
 
1669
-    // find frame with lowest picture number
1669
+    /* find frame with lowest picture number */
1670 1670
     for (i = 1; s->delay_frames[i]; i++)
1671 1671
         if (s->delay_frames[i]->avframe.display_picture_number < out->avframe.display_picture_number) {
1672 1672
             out = s->delay_frames[i];
... ...
@@ -1685,11 +1716,15 @@ static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *data_size)
1685 1685
     return 0;
1686 1686
 }
1687 1687
 
1688
-// [DIRAC_STD] 9.6 Parse Info Header Syntax. parse_info()
1689
-// 4 byte start code + byte parse code + 4 byte size + 4 byte previous size
1688
+/**
1689
+ * Dirac Specification ->
1690
+ * 9.6 Parse Info Header Syntax. parse_info()
1691
+ * 4 byte start code + byte parse code + 4 byte size + 4 byte previous size
1692
+ */
1690 1693
 #define DATA_UNIT_HEADER_SIZE 13
1691 1694
 
1692
-//[DIRAC_STD] dirac_decode_data_unit makes reference to the while defined in 9.3 inside the function parse_sequence()
1695
+/* [DIRAC_STD] dirac_decode_data_unit makes reference to the while defined in 9.3
1696
+   inside the function parse_sequence() */
1693 1697
 static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int size)
1694 1698
 {
1695 1699
     DiracContext *s = avctx->priv_data;
... ...
@@ -1705,7 +1740,7 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
1705 1705
         if (s->seen_sequence_header)
1706 1706
             return 0;
1707 1707
 
1708
-        //[DIRAC_STD] 10. Sequence header
1708
+        /* [DIRAC_STD] 10. Sequence header */
1709 1709
         if (avpriv_dirac_parse_sequence_header(avctx, &s->gb, &s->source))
1710 1710
             return -1;
1711 1711
 
... ...
@@ -1715,25 +1750,25 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
1715 1715
             return -1;
1716 1716
 
1717 1717
         s->seen_sequence_header = 1;
1718
-    } else if (parse_code == pc_eos) { //[DIRAC_STD] End of Sequence
1718
+    } else if (parse_code == pc_eos) { /* [DIRAC_STD] End of Sequence */
1719 1719
         free_sequence_buffers(s);
1720 1720
         s->seen_sequence_header = 0;
1721 1721
     } else if (parse_code == pc_aux_data) {
1722
-        if (buf[13] == 1) {     // encoder implementation/version
1722
+        if (buf[13] == 1) {     /* encoder implementation/version */
1723 1723
             int ver[3];
1724
-            // versions older than 1.0.8 don't store quant delta for
1725
-            // subbands with only one codeblock
1724
+            /* versions older than 1.0.8 don't store quant delta for
1725
+               subbands with only one codeblock */
1726 1726
             if (sscanf(buf+14, "Schroedinger %d.%d.%d", ver, ver+1, ver+2) == 3)
1727 1727
                 if (ver[0] == 1 && ver[1] == 0 && ver[2] <= 7)
1728 1728
                     s->old_delta_quant = 1;
1729 1729
         }
1730
-    } else if (parse_code & 0x8) {  // picture data unit
1730
+    } else if (parse_code & 0x8) {  /* picture data unit */
1731 1731
         if (!s->seen_sequence_header) {
1732 1732
             av_log(avctx, AV_LOG_DEBUG, "Dropping frame without sequence header\n");
1733 1733
             return -1;
1734 1734
         }
1735 1735
 
1736
-        // find an unused frame
1736
+        /* find an unused frame */
1737 1737
         for (i = 0; i < MAX_FRAMES; i++)
1738 1738
             if (s->all_frames[i].avframe.data[0] == NULL)
1739 1739
                 pic = &s->all_frames[i];
... ...
@@ -1744,13 +1779,13 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
1744 1744
 
1745 1745
         avcodec_get_frame_defaults(&pic->avframe);
1746 1746
 
1747
-        //[DIRAC_STD] Defined in 9.6.1 ...
1748
-        s->num_refs    =  parse_code & 0x03; //[DIRAC_STD] num_refs()
1749
-        s->is_arith    = (parse_code & 0x48) == 0x08; //[DIRAC_STD] using_ac()
1750
-        s->low_delay   = (parse_code & 0x88) == 0x88; //[DIRAC_STD] is_low_delay()
1751
-        pic->avframe.reference = (parse_code & 0x0C) == 0x0C; //[DIRAC_STD]  is_reference()
1752
-        pic->avframe.key_frame = s->num_refs == 0; //[DIRAC_STD] is_intra()
1753
-        pic->avframe.pict_type = s->num_refs + 1; //Definition of AVPictureType in avutil.h
1747
+        /* [DIRAC_STD] Defined in 9.6.1 ... */
1748
+        s->num_refs    =  parse_code & 0x03;                   /* [DIRAC_STD] num_refs()      */
1749
+        s->is_arith    = (parse_code & 0x48) == 0x08;          /* [DIRAC_STD] using_ac()      */
1750
+        s->low_delay   = (parse_code & 0x88) == 0x88;          /* [DIRAC_STD] is_low_delay()  */
1751
+        pic->avframe.reference = (parse_code & 0x0C) == 0x0C;  /* [DIRAC_STD]  is_reference() */
1752
+        pic->avframe.key_frame = s->num_refs == 0;             /* [DIRAC_STD] is_intra()      */
1753
+        pic->avframe.pict_type = s->num_refs + 1;              /* Definition of AVPictureType in avutil.h */
1754 1754
 
1755 1755
         if (avctx->get_buffer(avctx, &pic->avframe) < 0) {
1756 1756
             av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
... ...
@@ -1761,11 +1796,11 @@ static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
1761 1761
         s->plane[1].stride = pic->avframe.linesize[1];
1762 1762
         s->plane[2].stride = pic->avframe.linesize[2];
1763 1763
 
1764
-        //[DIRAC_STD] 11.1 Picture parse. picture_parse()
1764
+        /* [DIRAC_STD] 11.1 Picture parse. picture_parse() */
1765 1765
         if (dirac_decode_picture_header(s))
1766 1766
             return -1;
1767 1767
 
1768
-        //[DIRAC_STD] 13.0 Transform data syntax. transform_data()
1768
+        /* [DIRAC_STD] 13.0 Transform data syntax. transform_data() */
1769 1769
         if (dirac_decode_frame_internal(s))
1770 1770
             return -1;
1771 1771
     }
... ...
@@ -1780,7 +1815,7 @@ static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
1780 1780
     int buf_size = pkt->size;
1781 1781
     int i, data_unit_size, buf_idx = 0;
1782 1782
 
1783
-    // release unused frames
1783
+    /* release unused frames */
1784 1784
     for (i = 0; i < MAX_FRAMES; i++)
1785 1785
         if (s->all_frames[i].avframe.data[0] && !s->all_frames[i].avframe.reference) {
1786 1786
             avctx->release_buffer(avctx, &s->all_frames[i].avframe);
... ...
@@ -1790,37 +1825,37 @@ static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
1790 1790
     s->current_picture = NULL;
1791 1791
     *data_size = 0;
1792 1792
 
1793
-    // end of stream, so flush delayed pics
1793
+    /* end of stream, so flush delayed pics */
1794 1794
     if (buf_size == 0)
1795
-      return get_delayed_pic(s, (AVFrame *)data, data_size);
1795
+        return get_delayed_pic(s, (AVFrame *)data, data_size);
1796 1796
 
1797 1797
     for (;;) {
1798
-      //[DIRAC_STD] Here starts the code from parse_info() defined in 9.6
1799
-      //[DIRAC_STD] PARSE_INFO_PREFIX = "BBCD" as defined in ISO/IEC 646
1800
-        // BBCD start code search
1798
+        /*[DIRAC_STD] Here starts the code from parse_info() defined in 9.6
1799
+          [DIRAC_STD] PARSE_INFO_PREFIX = "BBCD" as defined in ISO/IEC 646
1800
+          BBCD start code search */
1801 1801
         for (; buf_idx + DATA_UNIT_HEADER_SIZE < buf_size; buf_idx++) {
1802 1802
             if (buf[buf_idx  ] == 'B' && buf[buf_idx+1] == 'B' &&
1803 1803
                 buf[buf_idx+2] == 'C' && buf[buf_idx+3] == 'D')
1804 1804
                 break;
1805 1805
         }
1806
-        //BBCD found or end of data
1806
+        /* BBCD found or end of data */
1807 1807
         if (buf_idx + DATA_UNIT_HEADER_SIZE >= buf_size)
1808 1808
             break;
1809 1809
 
1810 1810
         data_unit_size = AV_RB32(buf+buf_idx+5);
1811 1811
         if (buf_idx + data_unit_size > buf_size) {
1812 1812
             av_log(s->avctx, AV_LOG_ERROR,
1813
-                "Data unit with size %d is larger than input buffer, discarding\n",
1814
-                data_unit_size);
1813
+                   "Data unit with size %d is larger than input buffer, discarding\n",
1814
+                   data_unit_size);
1815 1815
             buf_idx += 4;
1816 1816
             continue;
1817 1817
         }
1818
-        // [DIRAC_STD] dirac_decode_data_unit makes reference to the while defined in 9.3 inside the function parse_sequence()
1818
+        /* [DIRAC_STD] dirac_decode_data_unit makes reference to the while defined in 9.3 inside the function parse_sequence() */
1819 1819
         if (dirac_decode_data_unit(avctx, buf+buf_idx, data_unit_size))
1820
-          {
1820
+        {
1821 1821
             av_log(s->avctx, AV_LOG_ERROR,"Error in dirac_decode_data_unit\n");
1822 1822
             return -1;
1823
-          }
1823
+        }
1824 1824
         buf_idx += data_unit_size;
1825 1825
     }
1826 1826
 
... ...
@@ -1834,7 +1869,7 @@ static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
1834 1834
 
1835 1835
         if (add_frame(s->delay_frames, MAX_DELAY, s->current_picture)) {
1836 1836
             int min_num = s->delay_frames[0]->avframe.display_picture_number;
1837
-            // Too many delayed frames, so we display the frame with the lowest pts
1837
+            /* Too many delayed frames, so we display the frame with the lowest pts */
1838 1838
             av_log(avctx, AV_LOG_ERROR, "Delay frame overflow\n");
1839 1839
             delayed_frame = s->delay_frames[0];
1840 1840
 
... ...
@@ -1852,9 +1887,9 @@ static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
1852 1852
             *data_size = sizeof(AVFrame);
1853 1853
         }
1854 1854
     } else if (s->current_picture->avframe.display_picture_number == s->frame_number) {
1855
-        // The right frame at the right time :-)
1856
-      *(AVFrame*)data = s->current_picture->avframe;
1857
-      *data_size = sizeof(AVFrame);
1855
+        /* The right frame at the right time :-) */
1856
+        *(AVFrame*)data = s->current_picture->avframe;
1857
+        *data_size = sizeof(AVFrame);
1858 1858
     }
1859 1859
 
1860 1860
     if (*data_size)
... ...
@@ -1865,7 +1900,7 @@ static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
1865 1865
 
1866 1866
 AVCodec ff_dirac_decoder = {
1867 1867
     "dirac",
1868
-    AVMEDIA_TYPE_VIDEO,  //CODEC_TYPE_VIDEO --> AVMEDIA_TYPE_VIDEO
1868
+    AVMEDIA_TYPE_VIDEO,
1869 1869
     CODEC_ID_DIRAC,
1870 1870
     sizeof(DiracContext),
1871 1871
     dirac_decode_init,