Commit 16163e6b authored by Martin Storsjö's avatar Martin Storsjö

rtpdec_h264: Fix nal type counting after refactoring

This fixes builds with -DDEBUG after f0a87479.
Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
parent a3cc519d
...@@ -57,9 +57,12 @@ struct PayloadContext { ...@@ -57,9 +57,12 @@ struct PayloadContext {
#ifdef DEBUG #ifdef DEBUG
#define COUNT_NAL_TYPE(data, nal) data->packet_types_received[(nal) & 0x1f]++ #define COUNT_NAL_TYPE(data, nal) data->packet_types_received[(nal) & 0x1f]++
#define NAL_COUNTERS data->packet_types_received
#else #else
#define COUNT_NAL_TYPE(data, nal) do { } while (0) #define COUNT_NAL_TYPE(data, nal) do { } while (0)
#define NAL_COUNTERS NULL
#endif #endif
#define NAL_MASK 0x1f
static const uint8_t start_sequence[] = { 0, 0, 0, 1 }; static const uint8_t start_sequence[] = { 0, 0, 0, 1 };
...@@ -178,7 +181,8 @@ static int sdp_parse_fmtp_config_h264(AVFormatContext *s, ...@@ -178,7 +181,8 @@ static int sdp_parse_fmtp_config_h264(AVFormatContext *s,
static int h264_handle_packet_stap_a(AVFormatContext *ctx, AVPacket *pkt, static int h264_handle_packet_stap_a(AVFormatContext *ctx, AVPacket *pkt,
const uint8_t *buf, int len, const uint8_t *buf, int len,
int start_skip) int start_skip, int *nal_counters,
int nal_mask)
{ {
int pass = 0; int pass = 0;
int total_length = 0; int total_length = 0;
...@@ -209,7 +213,8 @@ static int h264_handle_packet_stap_a(AVFormatContext *ctx, AVPacket *pkt, ...@@ -209,7 +213,8 @@ static int h264_handle_packet_stap_a(AVFormatContext *ctx, AVPacket *pkt,
memcpy(dst, start_sequence, sizeof(start_sequence)); memcpy(dst, start_sequence, sizeof(start_sequence));
dst += sizeof(start_sequence); dst += sizeof(start_sequence);
memcpy(dst, src, nal_size); memcpy(dst, src, nal_size);
COUNT_NAL_TYPE(data, *src); if (nal_counters)
nal_counters[(*src) & nal_mask]++;
dst += nal_size; dst += nal_size;
} }
} else { } else {
...@@ -236,7 +241,8 @@ static int h264_handle_packet_stap_a(AVFormatContext *ctx, AVPacket *pkt, ...@@ -236,7 +241,8 @@ static int h264_handle_packet_stap_a(AVFormatContext *ctx, AVPacket *pkt,
} }
static int h264_handle_packet_fu_a(AVFormatContext *ctx, AVPacket *pkt, static int h264_handle_packet_fu_a(AVFormatContext *ctx, AVPacket *pkt,
const uint8_t *buf, int len) const uint8_t *buf, int len,
int *nal_counters, int nal_mask)
{ {
uint8_t fu_indicator, fu_header, start_bit, nal_type, nal; uint8_t fu_indicator, fu_header, start_bit, nal_type, nal;
int ret; int ret;
...@@ -257,7 +263,8 @@ static int h264_handle_packet_fu_a(AVFormatContext *ctx, AVPacket *pkt, ...@@ -257,7 +263,8 @@ static int h264_handle_packet_fu_a(AVFormatContext *ctx, AVPacket *pkt,
len -= 2; len -= 2;
if (start_bit) { if (start_bit) {
COUNT_NAL_TYPE(data, nal_type); if (nal_counters)
nal_counters[nal_type & nal_mask]++;
/* copy in the start sequence, and the reconstructed nal */ /* copy in the start sequence, and the reconstructed nal */
if ((ret = av_new_packet(pkt, sizeof(start_sequence) + sizeof(nal) + len)) < 0) if ((ret = av_new_packet(pkt, sizeof(start_sequence) + sizeof(nal) + len)) < 0)
return ret; return ret;
...@@ -308,7 +315,8 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data, ...@@ -308,7 +315,8 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data,
// consume the STAP-A NAL // consume the STAP-A NAL
buf++; buf++;
len--; len--;
result = h264_handle_packet_stap_a(ctx, pkt, buf, len, 0); result = h264_handle_packet_stap_a(ctx, pkt, buf, len, 0,
NAL_COUNTERS, NAL_MASK);
break; break;
case 25: // STAP-B case 25: // STAP-B
...@@ -322,7 +330,8 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data, ...@@ -322,7 +330,8 @@ static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data,
break; break;
case 28: // FU-A (fragmented nal) case 28: // FU-A (fragmented nal)
result = h264_handle_packet_fu_a(ctx, pkt, buf, len); result = h264_handle_packet_fu_a(ctx, pkt, buf, len,
NAL_COUNTERS, NAL_MASK);
break; break;
case 30: // undefined case 30: // undefined
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment