/** * @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit, * 0 if the unit should be skipped, 1 otherwise */ static int hls_nal_unit(HEVCNAL *nal, AVCodecContext *avctx) { GetBitContext *gb = &nal->gb; int nuh_layer_id; if (get_bits1(gb) != 0) return AVERROR_INVALIDDATA; nal->type = get_bits(gb, 6); nuh_layer_id = get_bits(gb, 6); nal->temporal_id = get_bits(gb, 3) - 1; if (nal->temporal_id < 0) return AVERROR_INVALIDDATA; av_log(avctx, AV_LOG_DEBUG, "nal_unit_type: %d(%s), nuh_layer_id: %d, temporal_id: %d\n", nal->type, nal_unit_name(nal->type), nuh_layer_id, nal->temporal_id); return nuh_layer_id == 0; }
/** * @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit, * 0 if the unit should be skipped, 1 otherwise */ static int hevc_parse_nal_header(H2645NAL *nal, void *logctx) { GetBitContext *gb = &nal->gb; int nuh_layer_id; if (get_bits1(gb) != 0) return AVERROR_INVALIDDATA; nal->type = get_bits(gb, 6); nuh_layer_id = get_bits(gb, 6); nal->temporal_id = get_bits(gb, 3) - 1; if (nal->temporal_id < 0) return AVERROR_INVALIDDATA; av_log(logctx, AV_LOG_DEBUG, "nal_unit_type: %d(%s), nuh_layer_id: %d, temporal_id: %d\n", nal->type, nal_unit_name(nal->type), nuh_layer_id, nal->temporal_id); return nuh_layer_id == 0; }