Browse code

rtpdec_h264: Cleanup debug packet type counting

Signed-off-by: Martin Storsjö <martin@martin.st>

Martin Storsjö authored on 2012/05/05 06:28:25
Showing 1 changed files
... ...
@@ -57,6 +57,12 @@ struct PayloadContext {
57 57
 #endif
58 58
 };
59 59
 
60
+#ifdef DEBUG
61
+#define COUNT_NAL_TYPE(data, nal) data->packet_types_received[(nal) & 0x1f]++
62
+#else
63
+#define COUNT_NAL_TYPE(data, nal) do { } while (0)
64
+#endif
65
+
60 66
 static int sdp_parse_fmtp_config_h264(AVStream *stream,
61 67
                                       PayloadContext *h264_data,
62 68
                                       char *attr, char *value)
... ...
@@ -188,9 +194,7 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data,
188 188
         av_new_packet(pkt, len + sizeof(start_sequence));
189 189
         memcpy(pkt->data, start_sequence, sizeof(start_sequence));
190 190
         memcpy(pkt->data + sizeof(start_sequence), buf, len);
191
-#ifdef DEBUG
192
-        data->packet_types_received[nal & 0x1f]++;
193
-#endif
191
+        COUNT_NAL_TYPE(data, nal);
194 192
         break;
195 193
 
196 194
     case 24:                   // STAP-A (one packet, multiple nals)
... ...
@@ -224,9 +228,7 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data,
224 224
                             memcpy(dst, start_sequence, sizeof(start_sequence));
225 225
                             dst += sizeof(start_sequence);
226 226
                             memcpy(dst, src, nal_size);
227
-#ifdef DEBUG
228
-                            data->packet_types_received[*src & 0x1f]++;
229
-#endif
227
+                            COUNT_NAL_TYPE(data, *src);
230 228
                             dst += nal_size;
231 229
                         }
232 230
                     } else {
... ...
@@ -287,10 +289,8 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data,
287 287
             buf++;
288 288
             len--;
289 289
 
290
-#ifdef DEBUG
291 290
             if (start_bit)
292
-                data->packet_types_received[nal_type]++;
293
-#endif
291
+                COUNT_NAL_TYPE(data, nal_type);
294 292
             if (start_bit) {
295 293
                 /* copy in the start sequence, and the reconstructed nal */
296 294
                 av_new_packet(pkt, sizeof(start_sequence) + sizeof(nal) + len);