rtpdec_h264: added function to get NALU name

This commit is contained in:
Martin Pulec
2023-08-11 09:29:16 +02:00
parent 8c5f0a6645
commit 72ab033473
4 changed files with 35 additions and 14 deletions

View File

@@ -1692,7 +1692,7 @@ then
LIBAVCODEC_AUDIO_CODEC_OBJ="$LIBAVCODEC_COMMON src/audio/codec/libavcodec.o"
LIBAVCODEC_COMPRESS_OBJ="$LIBAVCODEC_COMMON $LIBAVCODEC_VIDEO $HW_ACC_OBJ src/video_compress/libavcodec.o"
LIBAVCODEC_DECOMPRESS_OBJ="$LIBAVCODEC_COMMON $LIBAVCODEC_VIDEO $HW_ACC_OBJ src/video_decompress/libavcodec.o"
LIBAVCODEC_DECOMPRESS_OBJ="$LIBAVCODEC_COMMON $LIBAVCODEC_VIDEO $HW_ACC_OBJ src/video_decompress/libavcodec.o src/rtp/rtpdec_h264.o src/utils/h264_stream.o"
if test $system = MacOSX; then
LIBAVCODEC_DECOMPRESS_OBJ="$LIBAVCODEC_DECOMPRESS_OBJ src/hwaccel_videotoolbox.o"
fi

View File

@@ -344,4 +344,24 @@ int width_height_from_SDP(int *widthOut, int *heightOut , unsigned char *data, i
return 0;
}
const char *
get_nalu_name(int type)
{
_Thread_local static char buf[32];
switch (type) {
case NAL_IDR:
return "H264 IDR";
case NAL_SEI:
return "H264 SEI";
case NAL_SPS:
return "H264 SPS";
case NAL_HEVC_VPS:
return "HEVC VPS";
default:
snprintf(buf, sizeof buf, "(NALU %d)", type);
return buf;
}
}
// vi: set et sw=4 :

View File

@@ -48,13 +48,16 @@
extern "C" {
#endif
#define NAL_MIN 1
#define NAL_IDR 5
#define NAL_SEI 6
#define NAL_SPS 7
#define NAL_MAX 23
#define NAL_HEVC_VPS 32
enum {
// H.264
NAL_MIN = 1,
NAL_IDR = 5,
NAL_SEI = 6,
NAL_SPS = 7,
NAL_MAX = 23,
// HEVC
NAL_HEVC_VPS = 32,
};
struct video_frame;
@@ -71,6 +74,7 @@ struct coded_data;
int decode_frame_h264(struct coded_data *cdata, void *decode_data);
int width_height_from_SDP(int *widthOut, int *heightOut , unsigned char *data, int data_len);
const char *get_nalu_name(int type);
#ifdef __cplusplus
}

View File

@@ -817,20 +817,17 @@ static _Bool check_first_sps_vps(struct state_libavcodec_decompress *s, unsigned
nalu_type = first_nal[0] >> 1;
}
s->sps_vps_found = 1;
switch (nalu_type) {
case NAL_SPS:
log_msg(LOG_LEVEL_VERBOSE,
MOD_NAME "Received H.264 SPS NALU, decoding begins.\n");
return 1;
case NAL_HEVC_VPS:
s->sps_vps_found = 1;
log_msg(LOG_LEVEL_VERBOSE,
MOD_NAME "Received HEVC VPS NALU, decoding begins.\n");
MOD_NAME "Received %s NALU, decoding begins.\n",
get_nalu_name(nalu_type));
return 1;
default:
log_msg(LOG_LEVEL_WARNING,
MOD_NAME "Waiting for first SPS/VPS NALU...\n");
s->sps_vps_found = 0;
return 0;
}
}